votca 2024.2-dev
|
class to generate histograms More...
#include <histogramnew.h>
Public Member Functions | |
void | Initialize (double min, double max, Index nbins) |
Initialize the HistogramNew. | |
void | Process (const double &v, double scale=1.0) |
process a data point | |
template<typename iterator_type > | |
void | ProcessRange (const iterator_type &begin, const iterator_type &end) |
process a range of data using iterator interface | |
double | getMin () const |
get the lower bound of the histogram intervaö | |
double | getMax () const |
get the upper bound of the histogram intervaö | |
Index | getNBins () const |
Get number of grid points. | |
double | getMinBinVal () const |
Get the count of the bin with the fewest counts. | |
double | getMaxBinVal () const |
Get the count of the bin with the maximum counts. | |
std::pair< double, double > | getInterval (Index bin) const |
Given the bin number get the Inverval bounds. | |
double | getStep () const |
get the grid of histogram | |
void | Normalize () |
normalize the histogram that the integral is 1 | |
void | Clear () |
clear all data | |
Table & | data () |
get access to content of histogram | |
const Table & | data () const |
void | setPeriodic (bool periodic) |
set whether interval is periodic | |
Private Member Functions | |
void | Initialize_ () |
Private Attributes | |
double | min_ = 0 |
double | max_ = 0 |
double | step_ = 0 |
bool | periodic_ = false |
Index | nbins_ = 100 |
Table | data_ |
class to generate histograms
This class produces a bin centered histogram out of a vector of values. The min and max values that are provided with the initialization function will place bins at those positions. For example if I want to create a histogram for 0 to 5 with bins centered at 0 and 5, I could do:
HistogramNew hn; double min_value = 0.0; double max_value = 5.0; Index number_bins = 6; hn.Initialize(min_value, max_value, number_bins);
This would produce a histogram with bins centered at the positions shown. below. The upper and lower bounds for each bin are also shown:
Bin: 1 2 3 4 5 6 Pos: 0.0 1.0 2.0 3.0 4.0 5.0 Upper Bound: 0.5 1.5 2.5 3.5 4.5 5.5 Lower Bound:-0.5 0.5 1.5 2.5 3.5 4.5
Step Size: 1.0
You also have the option to change the histogram to a periodic bin centered histogram by setting the periodic value to true;
hn.setPeriodic(true);
This has the effect of rearranging the step size. The new histogram would look like this:
Bin: 1 2 3 4 5 6 1 Pos: 0.000 0.833 1.667 2.500 3.333 4.167 5.000 Upper Bound: 0.416 1.249 2.082 2.910 3.750 4.580 0.416 Upper Bound: 4.580 0.416 1.249 2.082 2.910 3.750 4.580
Step Size: 0.833
Note that the bin in position 1 cycles back after bin 6 and that the step size is smaller this is a result of maintaining the same number of bins to be clear bin 1 is responsible for any values that fall between
0.00 - 0.416 and 4.580 - 5.00
Definition at line 77 of file histogramnew.h.
void votca::tools::HistogramNew::Clear | ( | ) |
clear all data
Definition at line 91 of file histogramnew.cc.
|
inline |
get access to content of histogram
Definition at line 157 of file histogramnew.h.
|
inline |
Definition at line 158 of file histogramnew.h.
pair< double, double > votca::tools::HistogramNew::getInterval | ( | Index | bin | ) | const |
Given the bin number get the Inverval bounds.
[in] | bin | - pass in the index of the bin |
Definition at line 76 of file histogramnew.cc.
|
inline |
get the upper bound of the histogram intervaö
Definition at line 111 of file histogramnew.h.
double votca::tools::HistogramNew::getMaxBinVal | ( | ) | const |
Get the count of the bin with the maximum counts.
Definition at line 74 of file histogramnew.cc.
|
inline |
get the lower bound of the histogram intervaö
Definition at line 105 of file histogramnew.h.
double votca::tools::HistogramNew::getMinBinVal | ( | ) | const |
Get the count of the bin with the fewest counts.
Definition at line 72 of file histogramnew.cc.
|
inline |
Get number of grid points.
Definition at line 117 of file histogramnew.h.
|
inline |
void votca::tools::HistogramNew::Initialize | ( | double | min, |
double | max, | ||
Index | nbins ) |
Initialize the HistogramNew.
min | lower bound of interval |
max | upper bound of interval |
nbins | number of bins |
Definition at line 48 of file histogramnew.cc.
|
private |
Definition at line 28 of file histogramnew.cc.
void votca::tools::HistogramNew::Normalize | ( | ) |
normalize the histogram that the integral is 1
Definition at line 84 of file histogramnew.cc.
void votca::tools::HistogramNew::Process | ( | const double & | v, |
double | scale = 1.0 ) |
process a data point
v | value of this point |
scale | weighting of this point, bin of v is increased by scale instead of 1 |
Definition at line 55 of file histogramnew.cc.
|
inline |
process a range of data using iterator interface
Definition at line 182 of file histogramnew.h.
|
inline |
set whether interval is periodic
periodic | is periodic |
Definition at line 164 of file histogramnew.h.
|
private |
Definition at line 173 of file histogramnew.h.
|
private |
Definition at line 169 of file histogramnew.h.
|
private |
Definition at line 168 of file histogramnew.h.
|
private |
Definition at line 172 of file histogramnew.h.
|
private |
Definition at line 171 of file histogramnew.h.
|
private |
Definition at line 170 of file histogramnew.h.