triqs.stat.histograms.Histogram
- class triqs.stat.histograms.Histogram
Bases:
objectClass representing a histogram on a given interval.
The histogram is defined on the interval \([a, b]\) with the following values for the center of its bins:
\[g_n = a + n h = a + n \frac{b - a}{N - 1} \; .\]Here, \(N\) is the number of bins in the histogram, \(h\) is the bin size and \(n = 0, 1, \ldots, N - 1\) is the index of the bin.
That means that each bin is of the same size \(h\), except for the first and last bins, which have a size of \(h / 2\).
Values are added to the histogram using the streaming operator <<. For example, hist << 1.5 adds the value 1.5 to the histogram hist.
When a value is added to the histogram, it first determines into which bin the value falls and then increases the count of that bin. If the value is outside of the interval, it is discarded. Additionally, the histogram keeps track of the total number of data points as well as the number of lost points that fall outside of the interval.
Dispatched C++ constructor(s).
[1] () [2] (a: int, b: int) [3] (a: float, b: float, nbins: int)
[1] Default constructor leaves the histogram in a valid but unusable state.
[2] Construct a histogram on the interval \([a, b]\) with a bin size of 1, except for the first and last bins, which have a size of 0.5.
The histogram will have a total of \(N = b - a + 1\) bins.
If \(a \geq b\), an exception is thrown.
[3] Construct a histogram on the interval \([a, b]\) with the given number \(N\) of bins.
The bin size is set to \(h = (b - a) / (N - 1)\). The first and last bins have a size of \(h / 2\) .
If \(a \geq b\) or if the number of bins is smaller than 2, an exception is thrown.
- Parameters:
- aint, float
Lower bound of the interval.
- bint, float
Upper bound of the interval.
- nbinsint
Number of bins.
Attributes
Get the data stored in the histogram.
Get the domain on which the histogram is defined.
Get the number of data points that have been added to the histogram.
Get the number of data points that fell outside of the interval and were discarded.
Methods
Reset the histogram to its initial state, i.e. with no data points added to it.
Get the position of the center of the n-th bin.