Go to the documentation of this file.
74 template<
typename Num_T>
80 Histogram(Num_T from = Num_T(0), Num_T
to = Num_T(99),
int n_bins = 100);
85 void setup(Num_T from, Num_T
to,
int n_bins);
95 void reset() { trials_cnt = 0; bins.zeros(); };
97 int get_bin(
int ix)
const {
return bins(ix); };
140 template<
class Num_T>
144 setup(from,
to, n_bins);
147 template<
class Num_T>
151 lo_vals.set_size(n_bins);
152 hi_vals.set_size(n_bins);
153 center_vals.set_size(n_bins);
154 bins.set_size(n_bins);
156 step = (
to - from) / (num_bins - 1);
158 lo_vals = center_vals - step / 2;
159 hi_vals = center_vals + step / 2;
163 template<
class Num_T>
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;
185 template<
class Num_T>
188 for (
int i = 0; i < values.
length(); i++)
192 template<
class Num_T>
195 for (
int i = 0; i < values.
rows(); i++)
196 for (
int j = 0; j < values.
cols(); j++)
197 update(values(i, j));
200 template<
class Num_T>
204 for (
int j = 0; j < num_bins; j++)
205 pdf(j) =
static_cast<double>(bins(j)) / trials_cnt;
209 template<
class Num_T>
214 for (
int j = 0; j < num_bins; j++)
215 cdf(j) =
static_cast<double>(tmp(j)) / trials_cnt;
223 #endif // #ifndef HISTOGRAM_H
int length() const
The size of the vector.
Vec< Num_T > get_bin_centers() const
Access to bin center values (all bins)
int get_bin(int ix) const
Access to single bin counter.
Histogram(Num_T from=Num_T(0), Num_T to=Num_T(99), int n_bins=100)
int bins_num() const
Current number of bins.
void update(Num_T value)
Histogram update.
int trials_num() const
Current trials counter.
Histogram computation class.
Matrix Class Definitions.
int rows() const
The number of rows.
Num_T get_bin_left(int ix) const
Access to left boundary of single bin.
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 get_pdf() const
Experimental Probability Density Function (PDF) computation.
vec linspace(double from, double to, int points)
linspace (works in the same way as the MATLAB version)
int cols() const
The number of columns.
ivec get_bins() const
Access to histogram as a vector.
T to(double x)
Convert double to T.
Vec< T > cumsum(const Vec< T > &v)
Cumulative sum of all elements in the vector.
~Histogram()
Default destructor.
void setup(Num_T from, Num_T to, int n_bins)
Histogram setup.
Vec< Num_T > get_bin_rights() const
Access to right boundary of bin intervals (all bins)
Vec< Num_T > get_bin_lefts() const
Access to left boundary of bin intervals (all bins)
void reset()
Bins reset, so accumulation can be restarted.
vec get_cdf() const
Experimental Cumulative Density Function (CDF) computation.
Generated on Mon Apr 25 2022 14:03:04 for IT++ by Doxygen 1.8.17