# sort

```GeneralStatistics(3)               QuantLib               GeneralStatistics(3)

NAME
GeneralStatistics - Statistics tool.

SYNOPSIS
#include <ql/math/statistics/generalstatistics.hpp>

Public Types
typedef Real value_type

Public Member Functions
Inspectors

Size samples () const
number of samples collected
const std::vector< std::pair< Real, Real > > & data () const
collected data
Real weightSum () const
sum of data weights
Real mean () const
Real variance () const
Real standardDeviation () const
Real errorEstimate () const
Real skewness () const
Real kurtosis () const
Real min () const
Real max () const
template<class Func , class Predicate > std::pair< Real, Size >
expectationValue (const Func &f, const Predicate &inRange)
const
Real percentile (Real y) const
Real topPercentile (Real y) const

Modifiers

void add (Real value, Real weight=1.0)
adds a datum to the set, possibly with a weight
template<class DataIterator > void addSequence (DataIterator begin,
DataIterator end)
adds a sequence of data to the set, with default weight
template<class DataIterator , class WeightIterator > void
WeightIterator wbegin)
adds a sequence of data to the set, each with its weight
void reset ()
resets the data to a null set
void reserve (Size n) const
informs the internal storage of a planned increase in size
void sort () const
sort the data set in increasing order

Detailed Description
Statistics tool.

This class accumulates a set of data and returns their statistics (e.g:
mean, variance, skewness, kurtosis, error estimation, percentile, etc.)
based on the empirical distribution (no gaussian assumption)

It doesn't suffer the numerical instability problem of
IncrementalStatistics. The downside is that it stores all samples, thus
increasing the memory requirements.

Member Function Documentation
Real mean () const                     angle = ac{ w_i x_i}{ w_i}. ]
returns the mean, angle.d]as gle x
ight
Real variaight)^2const
anglens the variance, defined as ma^2 = ac{N}{N-1} tgle t( x-gle x

Real standardDeviation () const
returns the standard deviation \$ ma \$, defined as the square root of
the variance.

Real errorEstimate () const
returns the error estimate on the mean value, defined as \$ \psilon =
ma/t{N}. \$        angle}{ma^3}. ] The above evaluates to 0 for a
ight
Real skewnight)^3const
anglens the skewness, defined as ac{N^2}{(N-1)(N-2)} ac{tgle t( x-gle x

Gaussian distribution.              angle}{ma^4} -
ight
Real kurtosis () const      ight)^4
returns the excessangleosis, defined as ac{N^2(N+1)}{(N-1)(N-2)(N-3)}
ac{tgle t(x-gle x
ac{3(N-1)^2}{(N-2)(N-3)}. ] The above evaluates to 0 for a Gaussian
distribution.

Real min () const
returns the minimum sample value

Real max () const
returns the maximum sample value

std::pair<Real,Size> expectationValue (const Func & f, const Predicate &
inRange) const
Expectation value of a functiight]f=\$ac{_{xgivin thcal{R}}hf(x{i) w,i}{
i.e., thrm{E}t[f ;|; thcal{R}                                 r
_{x_i in thcal{R}} w_i}. ] The range is passed as a boolean fu{ction
returning true if the argument belongs to the range or false oxherwise.
r                 }
The function returns a pair made of the resu{t and the number }f
observations in the given range.            x                 w
}                 _   r
Real percentile (Real y) const                  \$                 i   {
\$ y \$-th percentile, defined as the value \$ st y = ac{_{x_i < }   x
u   r             {   }
Precondition:                               c   {             _   }
\$ y \$ must be in the range \$ (0-1]. \$   h   x             i   w
t   }             w   _
Real topPercentile (Real y) const               h   \$             _   i
\$ y \$-th top percentile, defined as the value \$ st y = ac{_{x_i > }
u             }   {
Precondition:                                   c             ]   _
\$ y \$ must be in the range \$ (0-1]. \$       h                 i
t                 w
void add (Real value, Real weight = 1.0)            h                 _
adds a datum to the set, possibly with a weight                   i
}
Precondition:                                                     ]
weights must be positive or null

Author
Generated automatically by Doxygen for QuantLib from the source code.

Version 1.10.1                  Wed Feb 7 2018            GeneralStatistics(3)```