C++Guns – RoboBlog

03.02.2019

C++ Guns: ACPL proudly presents: Histogram2D

Filed under: Allgemein — Tags: — Thomas @ 21:02

See also
ACPL: Histogram1D
ACPL: BinaryHeap

Create even 2D Histogram in a fast and intuitive way.
Define TWO access functions, Axis, Range, Titles, get stochastic moments for every dimension. Enjoy the 2D ASCII art output.
See source code and more code examples at ACPL Histogram 2D

std::vector<std::pair<double,double>> values;
auto temp     = [](const std::pair<double, double>& p){ return p.first; };
auto pressure = [](const std::pair<double, double>& p){ return p.second; };

HistogramAxis Xaxis("temp [degree]",       FixBinWidth{0.5}, DataIntervalClosed{-4.0,7.0});
HistogramAxis Yaxis("air pressure [hPa]",  FixBinSize{20},   makeDataIntervalClosed(values, pressure));
Histogram2D hist = Histogram2D("City temperature VS air pressure",  Xaxis, temp, Yaxis, pressure, values);
std::cout << hist;
City temperature VS air pressure
Axis: temp [degree]
Number of bins: 22 bin width 0.5
Under/ Overflow count: 4 14
           min    max   avg    var    std 
Histogram -4 7 3.56703 6.43098 2.53594
Data      -4.5 7.6 3.62 7.27079 2.69644  
Axis: air pressure [hPa]
Number of bins: 20 bin width 1.2
Under/ Overflow count: 0 0
           min    max   avg    var    std 
Histogram 1014 1038 1030.45 40.2583 6.34494
Data      1014 1038 1030.45 40.2583 6.34494
      1038 |
         a |
         i |
         r |
           |
         p |
         r |
         e |
         s |
         s |
         u |
         r |
         e |
           |
         [ |
         h |
         P |
         a |
         ] |
      1014 |
           +-------------------------
            -4                 7
              temp [degree]

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress