yat  0.14.5pre
Public Member Functions | List of all members
theplu::yat::statistics::Percentiler Class Reference

Functor to calculate percentile of a range. More...

#include <yat/statistics/Percentiler.h>

Public Member Functions

 Percentiler (double perc=50, bool sorted=false)
 
template<typename RandomAccessIterator >
double operator() (RandomAccessIterator first, RandomAccessIterator last) const
 

Detailed Description

Functor to calculate percentile of a range.

Since
New in yat 0.5

Constructor & Destructor Documentation

theplu::yat::statistics::Percentiler::Percentiler ( double  perc = 50,
bool  sorted = false 
)
Parameters
percpercentile to calculate [0,100]. Default value is 50, which implies class will calculate median.
sortedif true class assumes that ranges are already sorted, if false the range will copied to a new range which is sorted.

Member Function Documentation

template<typename RandomAccessIterator >
double theplu::yat::statistics::Percentiler::operator() ( RandomAccessIterator  first,
RandomAccessIterator  last 
) const
inline

Function is a non-mutable function, i.e., first and last can be const_iterators.

The Nth percentile is defined such that, for example, when having four numbers $ 0.69 < 1.41 < 3.14 < 28 $, the Nth percentile is:

  • $ 0.69 $ if $ N < 25 $
  • $ (0.69+1.41)/2 $ if $ N=25 $
  • $ 1.41 $ if $ 25 < N < 50 $
  • $ (1.41+3.14)/2 $ if $ N=50 $
  • $ 3.14 $ if $ 50 < N < 75 $
  • $ (3.14+28)/2 $ if $ N=75 $
  • $ 28 $ if $ 75 < N $

Similarily, if we have a weighted range $ x_0=0.69, w_0=1 ; x_1=1.41, w_1=0 ; x_2=3.14, w_2=0.5 ; x_3=28, w_3=0.5 $, we calculate the accumulated normalized weight $ S_k = \frac {100}{\sum w_i}\sum_{i=0}^k w_i $ and the percentile is

  • $ 0.69 $ if $ N < S_0 $
  • $ (0.69+3.14)/2 $ if $ N=S_0 $
  • $ 3.14 $ if $ S_0 < N < S_2 $
  • $ (3.14+28)/2 $ if $ N=S_2 $
  • $ 28 $ if $ S_2 < N $

Note, that data point with weight zero is completely ignored.

Type Requirements:

Returns
percentile of range

The documentation for this class was generated from the following file:

Generated on Tue Sep 26 2017 02:33:30 for yat by  doxygen 1.8.5