geirs2Panic  Richard J. Mathar
Fits header keyword batch editor
 All Classes Files Functions Variables Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
Histo Class Reference

#include <Histo.h>

Collaboration diagram for Histo:
Collaboration graph

Public Member Functions

 Histo ()
 Constructor. More...
 
 Histo (const valarray< float > &arr, const int Nbin, const double range[], string &nam)
 
 Histo (const valarray< float > &arr, const int Nbin, string &nam)
 Constructor. More...
 
 Histo (const valarray< float > &arr, string &nam)
 Constructor. More...
 
void dumpFil (const char *fname)
 Create the bins in xy gnuplot format. For each number in the histogram, a short horizontal line is produced, such that concatenation of these horizontal lines with straight line segments produces a step function along the x axis. More...
 

Static Public Member Functions

static int valRange (const valarray< float > &arr, double mimax[2])
 Determine smallest and largest value in all elements of the array. More...
 

Public Attributes

vector< int > cts
 The counts on a per-bin basis. More...
 
vector< int > cumCts
 The cumulative counts on a per-bin basis. More...
 
double strt
 The smallest range of the first bin. More...
 
double stride
 The width of each bin. More...
 
double perc [7]
 Percentile abscissas. More...
 
double mimax [3]
 Minimum and maximum value and arithmetic mean. More...
 
string name
 Some kind of file name or tag attached to this statistics. More...
 

Private Member Functions

void init (const valarray< float > &arr, const int Nbin, const double range[])
 Principal part of the constructor. More...
 

Detailed Description

Since
2013-01-29
Author
Richard J. Mathar

Constructor & Destructor Documentation

Histo::Histo ( )

Constructor.

Empty histogram. The main purpose of this construction is to allow allocations of vectors of histograms.

Since
2013-01-28
Author
Richard J. Mathar
Histo::Histo ( const valarray< float > &  arr,
const int  Nbin,
const double  range[],
string &  nam 
)
Histo::Histo ( const valarray< float > &  arr,
const int  Nbin,
string &  nam 
)

Constructor.

The range of the bins is automatically set to reach out to the smallest and largest value in the array.

Parameters
arrThe array of values to be binned.
NbinThe number of bins into which the values are split.
Since
2013-01-28
Author
Richard J. Mathar
Histo::Histo ( const valarray< float > &  arr,
string &  nam 
)

Constructor.

The number of bins is set equal to the square root of the number of values in the array. The range of the bins is automatically set to reach out to the smallest and largest value in the array.

Parameters
arrThe array of values to be binned.
Since
2013-01-28
Author
Richard J. Mathar

Member Function Documentation

int Histo::valRange ( const valarray< float > &  arr,
double  mimax[2] 
)
static

Determine smallest and largest value in all elements of the array.

NaN-values are not taken into account (ignored). In that sense, this function is an improvement relative to the undefined result if min() or max() of the array are taken as defined in the STL.

Parameters
[in]arrThe array to be scanned.
[out]mimaxThe minimum in [0], the maximum in [1]. If the array does not contain values that are not NaN's, both values are unchanged.
Returns
The number of non-NaN's in the array.
Since
2013-06-07
void Histo::dumpFil ( const char *  fname)

Create the bins in xy gnuplot format. For each number in the histogram, a short horizontal line is produced, such that concatenation of these horizontal lines with straight line segments produces a step function along the x axis.


Parameters
[in]fnameThe file to be generated.
void Histo::init ( const valarray< float > &  arr,
const int  Nbin,
const double  range[] 
)
private

Principal part of the constructor.

The statistics (minimum and maximum and the percentiles) is computed over the entire range of the arr-values that are not NaN's, not only over the values within the interval specified by the range argument.

Parameters
arrThe array of values to be binned.
NbinThe number of bins into which the values are split.
rangeThe minimum and maximum value in the first and last bin.
Todo:
Check that Nbin is larger than zero etc.
Since
2013-01-28
2013-02-22 percentiles added
2013-06-07 NaN's ignored.
2013-12-04 cumulative bins added
Author
Richard J. Mathar

Member Data Documentation

vector<int> Histo::cts

The counts on a per-bin basis.

Provides by its length an explicit count of the bins.

vector<int> Histo::cumCts

The cumulative counts on a per-bin basis.

cumCts[i] contains sum_{k=0..n} cts[k].

Since
2013-12-04
double Histo::strt

The smallest range of the first bin.

double Histo::stride

The width of each bin.

double Histo::perc[7]

Percentile abscissas.

[0] the 3 sigma level (left), [1] the 2 sigm left, [2] the 1 sigma left, [3] the median, [4] the 1 sigma right, [5] the 2 sigma right, [6] the 3 sigma right.

double Histo::mimax[3]

Minimum and maximum value and arithmetic mean.

Since
2013-06-07
string Histo::name

Some kind of file name or tag attached to this statistics.