QuantLib 0.3.6
User manual
Introduction to QuantLib
QuantLib components
Reference manual
|
GeneralStatistics Class Reference#include <ql/Math/generalstatistics.hpp>
List of all members.
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.
|
Public Member Functions |
|
Size | samples () const |
| number of samples collected
|
const std::vector< std::pair<
double, double > > & | data () const |
| collected data
|
double | weightSum () const |
| sum of data weights
|
double | mean () const |
double | variance () const |
double | standardDeviation () const |
double | errorEstimate () const |
double | skewness () const |
double | kurtosis () const |
double | min () const |
double | max () const |
template<class Func, class Predicate> std::pair< double, Size > | expectationValue (const Func &f, const Predicate &inRange) const |
double | percentile (double y) const |
double | topPercentile (double y) const |
|
void | add (double value, double 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 | addSequence (DataIterator begin, DataIterator end, WeightIterator wbegin) |
| adds a sequence of data to the set, each with its weight
|
void | reset () |
| resets the data to a null set
|
void | sort () const |
| sort the data set in increasing order
|
Member Function Documentation
|
returns the mean, defined as
|
double variance |
( |
|
) |
const |
|
|
returns the variance, defined as
|
double standardDeviation |
( |
|
) |
const |
|
|
returns the standard deviation , defined as the square root of the variance. |
double errorEstimate |
( |
|
) |
const |
|
|
returns the error estimate on the mean value, defined as |
double skewness |
( |
|
) |
const |
|
|
returns the skewness, defined as
The above evaluates to 0 for a Gaussian distribution. |
double kurtosis |
( |
|
) |
const |
|
|
returns the excess kurtosis, defined as
The above evaluates to 0 for a Gaussian distribution. |
|
returns the minimum sample value |
|
returns the maximum sample value |
std::pair<double,Size> expectationValue |
( |
const Func & |
f, |
|
|
const Predicate & |
inRange |
|
) |
const |
|
|
Expectation value of a function on a given range , i.e.,
The range is passed as a boolean function returning true if the argument belongs to the range or false otherwise.
The function returns a pair made of the result and the number of observations in the given range. |
double percentile |
( |
double |
y |
) |
const |
|
|
-th percentile, defined as the value such that
- Precondition:
must be in the range
|
double topPercentile |
( |
double |
y |
) |
const |
|
|
-th top percentile, defined as the value such that
- Precondition:
must be in the range
|
void add |
( |
double |
value, |
|
|
double |
weight = 1.0 |
|
) |
|
|
|
adds a datum to the set, possibly with a weight
- Precondition:
- weights must be positive or null
|
|