Skip to content

num::basic_histogram

Defined in header <stats/stats.hpp>

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

Fixed-bin histogram 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) Divide [lo,hi) into equally sized bins.
Index bin(Float x) const Return the containing bin, or nbins when x lies outside the interval.
Float bin_centre(Index b) const Return the center coordinate of bin b.
Float bin_width() const
void fill(Float x, Float weight = Float{1.0}) Accumulate a weighted observation when it lies inside the interval.
void reset()
Float total() const Return the total accumulated bin weight.
array<Float> pdf() const Normalise so that the histogram integrates to 1 (probability density).