74template<
typename Num_T>
95 void reset() { trials_cnt = 0; bins.zeros(); };
156 step = (
to -
from) / (num_bins - 1);
158 lo_vals = center_vals - step / 2;
159 hi_vals = center_vals + step / 2;
168 int end = num_bins - 1;
169 int test = (start + end) / 2;
171 while (start < end) {
172 if (value < lo_vals(test))
174 else if (value >= hi_vals(test))
178 test = (start + end) / 2;
204 for (
int j = 0;
j < num_bins;
j++)
205 pdf(
j) =
static_cast<double>(bins(
j)) / trials_cnt;
214 for (
int j = 0;
j < num_bins;
j++)
215 cdf(
j) =
static_cast<double>(
tmp(
j)) / trials_cnt;
void set_size(int n, bool copy=false)
Resizing an Array<T>.
int length() const
Returns the number of data elements in the array object.
Histogram computation class.
int bins_num() const
Current number of bins.
void reset()
Bins reset, so accumulation can be restarted.
~Histogram()
Default destructor.
Vec< Num_T > get_bin_rights() const
Access to right boundary of bin intervals (all bins)
Vec< Num_T > get_bin_centers() const
Access to bin center values (all bins)
Num_T get_bin_center(int ix) const
Access to bin center (single bin)
Num_T get_bin_right(int ix) const
Access to right boundary of single bin.
Vec< Num_T > get_bin_lefts() const
Access to left boundary of bin intervals (all bins)
ivec get_bins() const
Access to histogram as a vector.
int trials_num() const
Current trials counter.
Num_T get_bin_left(int ix) const
Access to left boundary of single bin.
int get_bin(int ix) const
Access to single bin counter.
T to(double x)
Convert double to T.
vec get_cdf() const
Experimental Cumulative Density Function (CDF) computation.
vec get_pdf() const
Experimental Probability Density Function (PDF) computation.
void setup(Num_T from, Num_T to, int n_bins)
Histogram setup.
Histogram(Num_T from=Num_T(0), Num_T to=Num_T(99), int n_bins=100)
void update(Num_T value)
Histogram update.
Vec< T > cumsum(const Vec< T > &v)
Cumulative sum of all elements in the vector.
vec linspace(double from, double to, int points)
linspace (works in the same way as the MATLAB version)
Matrix Class Definitions.