Skip to content

num::basic_histogram

Defined in header <stats/stats.hpp>

template <typename Float = double, std::integral Index = num::idx>
struct basic_histogram;

Histogram with equal bins over \([\ell, h)\).

Members

member description
array<Float> counts
Float lo = Float{0}
Float hi = Float{0}
Index nbins = 0
basic_histogram(Index nbins, Float lo, Float hi) Construct a histogram of nbins equal bins over \([\ell, h)\).
Index bin(Float x) const Return the bin of \(x\), or nbins outside \([\ell, h)\).
Float bin_centre(Index b) const Return the centre of bin \(b\).
Float bin_width() const
void fill(Float x, Float weight = Float{1.0}) Add \(x\) with weight weight, if it lies in the range.
void reset()
Float total() const Return the total weight.
array<Float> pdf() const Return the counts scaled to a probability density: \(\int p = 1\).