23#ifndef VCL_MATH_DISTRIBUTION_H
24#define VCL_MATH_DISTRIBUTION_H
26#include <vclib/types.h>
41template<
typename Scalar>
44 std::set<Scalar> mSet;
46 Scalar mMin = std::numeric_limits<Scalar>::max();
47 Scalar mMax = std::numeric_limits<Scalar>::lowest();
67 mMin = std::numeric_limits<Scalar>::max();
68 mMax = std::numeric_limits<Scalar>::lowest();
89 mAvg = mSum / mSet.size();
90 mSqrdAvg = mSqrdSum / mSet.size();
91 mRMS = std::sqrt(mSqrdAvg);
100 Scalar
min()
const {
return mMin; }
108 Scalar
max()
const {
return mMax; }
120 Scalar
sum()
const {
return mSum; }
138 Scalar
variance()
const {
return mSqrdAvg - mAvg * mAvg; }
157 int index = mSet.size() *
perc - 1;
160 auto it = mSet.begin();
161 std::advance(
it, index);
The Distribution class allows to collect a set of values and then compute some statistics like averag...
Definition distribution.h:43
Scalar min() const
Returns the minimum value of the distribution.
Definition distribution.h:100
Scalar variance() const
Returns the variance of the values of the distribution.
Definition distribution.h:138
uint size() const
Returns the number of values of the distribution.
Definition distribution.h:114
void clear()
Clears the distribution, removing all its values.
Definition distribution.h:64
Distribution()=default
Creates an empty distribution.
Scalar rootMeanSquare() const
Returns the root mean square of the values of the distribution.
Definition distribution.h:132
Scalar average() const
Returns the average of the values of the distribution.
Definition distribution.h:126
void add(Scalar v)
Adds a value to the distribution.
Definition distribution.h:80
Scalar sum() const
Returns the sum of the values of the distribution.
Definition distribution.h:120
Scalar max() const
Returns the maximum value of the distribution.
Definition distribution.h:108
Scalar percentile(Scalar perc) const
Returns the perc percentile of the values of the distribution.
Definition distribution.h:152
Scalar standardDeviation() const
Returns the standard deviation of the values of the distribution.
Definition distribution.h:144
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43