Theoretica
A C++ numerical and automatic mathematical library
|
Histogram class with running statistics, can be constructed from the parameters of the bins or from a dataset. More...
#include <histogram.h>
Public Member Functions | |
histogram (unsigned int bin_count, real range_min, real range_max) | |
Construct the histogram from the number of bins and the range. | |
template<typename Dataset , enable_vector< Dataset > = true> | |
histogram (const Dataset &data, unsigned int bin_count=0) | |
Construct the histogram from a set of data points, with the given number of bins. | |
void | insert (real x) |
Insert a new data point inside the histogram, updating the running statistics and the corresponding bin. | |
unsigned int | index (real x) const |
Find the bin index corresponding to a given data point. | |
unsigned int | number () const |
Get the number of data points inside the histogram. | |
std::vector< unsigned int > | bins () const |
Get a vector containing the bin counts of each bin. | |
real | max () const |
Get the biggest data point of the histogram. | |
real | min () const |
Get the smallest data point of the histogram. | |
real | mean () const |
Get the mean value of the histogram data. | |
real | tss () const |
Get the total sum of squares (TSS) computed using Welford's one-pass method. | |
real | operator() (real x) |
Evaluate the histogram like a step function which is zero outside the range of the histogram. | |
unsigned int | operator[] (unsigned int i) const |
Get the number of elements in the i-th bin. | |
std::string | to_string (const std::string &separator=" ", bool normalized=true, bool lower_extreme=false) const |
TO-DO Cumulative Distribution Function. | |
operator std::string () | |
Convert the histogram to string representation. | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const histogram &obj) |
Stream the histogram in string representation to an output stream (std::ostream) | |
Histogram class with running statistics, can be constructed from the parameters of the bins or from a dataset.
Elements are inserted one by one, updating the running statistics for the TSS, mean, maximum and minimum on each step.
Construct the histogram from the number of bins and the range.
The histogram is initialized from the arguments, without specifying any data points, which need to be added with insert().
bin_count | The number of bins |
range_min | The lower bound of the range |
range_max | The upper bound of the range |
Construct the histogram from a set of data points, with the given number of bins.
If the number of bins is not specified, it defaults to \([\sqrt{N}]\).
data | The set of data points |
bin_count | The number of bins (defaults to the square root of the number of points) |
Get a vector containing the bin counts of each bin.
Find the bin index corresponding to a given data point.
x | The value to find the bin index of (must be between range_min and range_max) |
Insert a new data point inside the histogram, updating the running statistics and the corresponding bin.
x | The value to insert |
|
inline |
Get the biggest data point of the histogram.
|
inline |
Get the mean value of the histogram data.
|
inline |
Get the smallest data point of the histogram.
Get the number of data points inside the histogram.
Evaluate the histogram like a step function which is zero outside the range of the histogram.
x | The point to evaluate the histogram function at |
Get the number of elements in the i-th bin.
i | The index of the bin |
|
inline |
TO-DO Cumulative Distribution Function.
Convert the histogram to string representation
separator | The string to print between row elements |
normalized | Whether to normalize the bin counts as a frequency (defaults to true). |
lower_extreme | Whether to print the lower extreme of the bins or use the mid point (defaults to false, using mid points). |
|
inline |
Get the total sum of squares (TSS) computed using Welford's one-pass method.