votca 2024-dev
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
votca::tools::HistogramNew Class Reference

class to generate histograms More...

#include <histogramnew.h>

Collaboration diagram for votca::tools::HistogramNew:
Collaboration graph
[legend]

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
 
Tabledata ()
 get access to content of histogram
 
const Tabledata () 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_
 

Detailed Description

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.

Member Function Documentation

◆ Clear()

void votca::tools::HistogramNew::Clear ( )

clear all data

Definition at line 91 of file histogramnew.cc.

◆ data() [1/2]

Table & votca::tools::HistogramNew::data ( )
inline

get access to content of histogram

Returns
table object with bins in x and values in y

Definition at line 157 of file histogramnew.h.

◆ data() [2/2]

const Table & votca::tools::HistogramNew::data ( ) const
inline

Definition at line 158 of file histogramnew.h.

◆ getInterval()

pair< double, double > votca::tools::HistogramNew::getInterval ( Index  bin) const

Given the bin number get the Inverval bounds.

Parameters
[in]bin- pass in the index of the bin
Returns
pair with upper and lower bounds of the interval of the bin

Definition at line 76 of file histogramnew.cc.

◆ getMax()

double votca::tools::HistogramNew::getMax ( ) const
inline

get the upper bound of the histogram intervaö

Returns
upper limit of interval

Definition at line 111 of file histogramnew.h.

◆ getMaxBinVal()

double votca::tools::HistogramNew::getMaxBinVal ( ) const

Get the count of the bin with the maximum counts.

Returns
maximum counts

Definition at line 74 of file histogramnew.cc.

◆ getMin()

double votca::tools::HistogramNew::getMin ( ) const
inline

get the lower bound of the histogram intervaö

Returns
lower limit of interval

Definition at line 105 of file histogramnew.h.

◆ getMinBinVal()

double votca::tools::HistogramNew::getMinBinVal ( ) const

Get the count of the bin with the fewest counts.

Returns
minimum counts

Definition at line 72 of file histogramnew.cc.

◆ getNBins()

Index votca::tools::HistogramNew::getNBins ( ) const
inline

Get number of grid points.

Returns
number of grid poitns

Definition at line 117 of file histogramnew.h.

◆ getStep()

double votca::tools::HistogramNew::getStep ( ) const
inline

get the grid of histogram

Returns
step per bin

Definition at line 141 of file histogramnew.h.

◆ Initialize()

void votca::tools::HistogramNew::Initialize ( double  min,
double  max,
Index  nbins 
)

Initialize the HistogramNew.

Parameters
minlower bound of interval
maxupper bound of interval
nbinsnumber of bins

Definition at line 48 of file histogramnew.cc.

◆ Initialize_()

void votca::tools::HistogramNew::Initialize_ ( )
private

Definition at line 28 of file histogramnew.cc.

◆ Normalize()

void votca::tools::HistogramNew::Normalize ( )

normalize the histogram that the integral is 1

Definition at line 84 of file histogramnew.cc.

◆ Process()

void votca::tools::HistogramNew::Process ( const double &  v,
double  scale = 1.0 
)

process a data point

Parameters
vvalue of this point
scaleweighting of this point, bin of v is increased by scale instead of 1

Definition at line 55 of file histogramnew.cc.

◆ ProcessRange()

template<typename iterator_type >
void votca::tools::HistogramNew::ProcessRange ( const iterator_type &  begin,
const iterator_type &  end 
)
inline

process a range of data using iterator interface

Definition at line 182 of file histogramnew.h.

◆ setPeriodic()

void votca::tools::HistogramNew::setPeriodic ( bool  periodic)
inline

set whether interval is periodic

Parameters
periodicis periodic

Definition at line 164 of file histogramnew.h.

Member Data Documentation

◆ data_

Table votca::tools::HistogramNew::data_
private

Definition at line 173 of file histogramnew.h.

◆ max_

double votca::tools::HistogramNew::max_ = 0
private

Definition at line 169 of file histogramnew.h.

◆ min_

double votca::tools::HistogramNew::min_ = 0
private

Definition at line 168 of file histogramnew.h.

◆ nbins_

Index votca::tools::HistogramNew::nbins_ = 100
private

Definition at line 172 of file histogramnew.h.

◆ periodic_

bool votca::tools::HistogramNew::periodic_ = false
private

Definition at line 171 of file histogramnew.h.

◆ step_

double votca::tools::HistogramNew::step_ = 0
private

Definition at line 170 of file histogramnew.h.


The documentation for this class was generated from the following files: