JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches
Collaboration diagram for Basic statistics:

Classes

struct  JKQTPStat5NumberStatistics
 represents the Five-Number Statistical Summary (minimum, median, maximum and two user-defined quantiles (as well as derived from these the inter quartile range)) More...
 

Functions

template<class InputIt >
void jkqtpstat5NumberStatistics (InputIt first, InputIt last, double *minimum, double minimumQuantile=0, double *median=nullptr, double *maximum=nullptr, double maximumQuantile=1, double quantile1Spec=0.25, double *quantile1=nullptr, double quantile2Spec=0.75, double *quantile2=nullptr, double *IQR=nullptr, double *IQRSignificance=nullptr, size_t *Noutput=nullptr)
 calculates the Five-Number Statistical Summary (minimum, median, maximum and two user-defined quantiles (as well as derived from these the inter quartile range)) of a given data range first ... last (5-value statistics, e.g. used for boxplots)
 
template<class InputIt >
JKQTPStat5NumberStatistics jkqtpstat5NumberStatistics (InputIt first, InputIt last, double quantile1Spec=0.25, double quantile2Spec=0.75, double minimumQuantile=0, double maximumQuantile=1.0)
 calculates the Five-Number Statistical Summary (minimum, median, maximum and two user-defined quantiles (as well as derived from these the inter quartile range)) of a given data range first ... last (5-value statistics, e.g. used for boxplots)
 
template<class InputIt , class OutputIt >
void jkqtpstat5NumberStatisticsAndOutliers (InputIt first, InputIt last, OutputIt outliersout, double *minimum=nullptr, double minimumQuantile=0, double *median=nullptr, double *maximum=nullptr, double maximumQuantile=1, double *quantile1=nullptr, double quantile1Spec=0.25, double *quantile2=nullptr, double quantile2Spec=0.75, double *IQR=nullptr, double *IQRSignificance=nullptr, size_t *Noutput=nullptr)
 calculates the Five-Number Statistical Summary (minimum, median, maximum and two user-defined quantiles (as well as derived from these the inter quartile range)) of a given data range first ... last (5-value statistics, e.g. used for boxplots)
 
template<class TVector , class OutputIt >
void jkqtpstat5NumberStatisticsAndOutliersOfSortedVector (const TVector &data, OutputIt outliersout, double *minimum=nullptr, double minimumQuantile=0, double *median=nullptr, double *maximum=nullptr, double maximumQuantile=1, double *quantile1=nullptr, double quantile1Spec=0.25, double *quantile2=nullptr, double quantile2Spec=0.75, double *IQR=nullptr, double *IQRSignificance=nullptr, size_t *Noutput=nullptr)
 calculates the Five-Number Statistical Summary (minimum, median, maximum and two user-defined quantiles (as well as derived from these the inter quartile range)) of a sorted vector
 
template<class TVector >
void jkqtpstat5NumberStatisticsOfSortedVector (const TVector &data, double *minimum=nullptr, double minimumQuantile=0, double *median=nullptr, double *maximum=nullptr, double maximumQuantile=1, double *quantile1=nullptr, double quantile1Spec=0.25, double *quantile2=nullptr, double quantile2Spec=0.75, double *IQR=nullptr, double *IQRSignificance=nullptr, size_t *Noutput=nullptr)
 calculates the Five-Number Statistical Summary (minimum, median, maximum and two user-defined quantiles (as well as derived from these the inter quartile range)) of a sorted vector
 
template<class InputIt >
double jkqtpstatAverage (InputIt first, InputIt last, size_t *Noutput=nullptr)
 calculates the average of a given data range first ... last
 
template<class InputIt >
double jkqtpstatCentralMoment (InputIt first, InputIt last, int order, double *averageOut=nullptr, size_t *Noutput=nullptr)
 calculates the given central moment $ \langle (X-\mu)^o\rangle $ of a given data range first ... last
 
template<class InputIt1 , class InputIt2 >
double jkqtpstatCorrelationCoefficient (InputIt1 first1, InputIt1 last1, InputIt2 first2, double *averageOut1=nullptr, double *averageOut2=nullptr, size_t *Noutput=nullptr)
 calculate empirical (Pearson's) correlation coefficient $ \rho_{x,y} $ between two given data ranges first1 ... last1 and first2 ... last2
 
template<class InputIt >
size_t jkqtpstatCount (InputIt first, InputIt last)
 calculates the number of valid values in the given data range first ... last
 
template<class InputIt , class OutputIt >
void jkqtpstatCumSum (InputIt first, InputIt last, OutputIt output)
 calculates the vector of cummulative (or partial) sums of a given data range first ... last
 
template<class InputIt , class OutputIt >
size_t jkqtpstatFilterGoodFloat (InputIt first, InputIt last, OutputIt output)
 filters the given data range first ... last for good floats (using JKQTPIsOKFloat() )
 
template<class InputIt >
double jkqtpstatMAD (InputIt first, InputIt last, double *median=nullptr, size_t *Noutput=nullptr)
 calculates the median absolute deviation about the median (MAD) of a given data range first ... last
 
template<class InputIt >
double jkqtpstatMaximum (InputIt first, InputIt last, InputIt *maxPos=nullptr, size_t *Noutput=nullptr)
 calculates the maximum value in the given data range first ... last
 
template<class InputIt >
double jkqtpstatMedian (InputIt first, InputIt last, size_t *Noutput=nullptr)
 calculates the median of a given data range first ... last
 
template<class InputIt >
double jkqtpstatMedianAndPartialSort (InputIt first, InputIt last)
 calculates the median of a given data range first ... last, this version partially sorts the range (i.e. no internal copy and checking for NAN-values is performed!)
 
template<class TVector >
double jkqtpstatMedianOfSortedVector (const TVector &data, size_t *Noutput=nullptr)
 calculates the median of a given sorted (!) data vector
 
template<class InputIt >
double jkqtpstatMinimum (InputIt first, InputIt last, InputIt *minPos=nullptr, size_t *Noutput=nullptr)
 calculates the minimum value in the given data range first ... last
 
template<class InputIt >
void jkqtpstatMinMax (InputIt first, InputIt last, double &min, double &max, InputIt *minPos=nullptr, InputIt *maxPos=nullptr, size_t *Noutput=nullptr)
 calculates the minimum and maximum values in the given data range first ... last
 
template<class InputIt , class FF >
double jkqtpstatModifiedSum (InputIt first, InputIt last, FF modifierFunctor, size_t *Noutput=nullptr)
 calculates the sum of a given data range first ... last of values, modifying each value with a given functor modifierFunctor before accumulating
 
template<class InputIt >
double jkqtpstatMoment (InputIt first, InputIt last, int order, size_t *Noutput=nullptr)
 calculates the given (non-central) moment $ \langle X^o\rangle $ of a given data range first ... last
 
template<class InputIt >
double jkqtpstatNMAD (InputIt first, InputIt last, double *median=nullptr, size_t *Noutput=nullptr)
 calculates the normalized median absolute deviation about the median (NMAD) of a given data range first ... last
 
template<class InputIt >
double jkqtpstatQuantile (InputIt first, InputIt last, double quantile, size_t *Noutput=nullptr)
 calculates the quantile -th quantile of a given data range first ... last
 
template<class InputIt >
double jkqtpstatSkewness (InputIt first, InputIt last, double *averageOut=nullptr, size_t *Noutput=nullptr)
 calculates the skewness $ \gamma_1=\mathbb{E}\left[\left(\frac{X-\mu}{\sigma}\right)^3\right] $ of a given data range first ... last
 
template<class InputIt >
double jkqtpstatStdDev (InputIt first, InputIt last, double *averageOut=nullptr, size_t *Noutput=nullptr)
 calculates the standard deviation $ \sigma_X=\sqrt{\mbox{Var}(X)} $ of a given data range first ... last
 
template<class InputIt >
double jkqtpstatSum (InputIt first, InputIt last, size_t *Noutput=nullptr)
 calculates the sum of a given data range first ... last
 
template<class InputIt >
double jkqtpstatSumSqr (InputIt first, InputIt last, size_t *Noutput=nullptr)
 calculates the sum of squares of a given data range first ... last
 
template<class InputIt >
double jkqtpstatVariance (InputIt first, InputIt last, double *averageOut=nullptr, size_t *Noutput=nullptr)
 calculates the variance $ \sigma_X^2=\mbox{Var}(X) $ of a given data range first ... last
 
template<class InputIt , class InputWeightIt >
double jkqtpstatWeightedAverage (InputIt first, InputIt last, InputWeightIt firstWeight, size_t *Noutput=nullptr)
 calculates the weighted average of a given data range first ... last
 
template<class InputIt , class InputWeightIt >
double jkqtpstatWeightedStdDev (InputIt first, InputIt last, InputWeightIt firstWeight, double *averageOut=nullptr, size_t *Noutput=nullptr)
 calculates the weighted standard deviation $ \sigma_X=\sqrt{\mbox{Var}(X)} $ of a given data range first ... last
 
template<class InputIt , class InputWeightIt >
double jkqtpstatWeightedVariance (InputIt first, InputIt last, InputWeightIt firstWeight, double *averageOut=nullptr, size_t *Noutput=nullptr)
 calculates the weighted variance $ \sigma_X^2=\mbox{Var}(X) $ of a given data range first ... last
 

Detailed Description

Function Documentation

◆ jkqtpstat5NumberStatistics() [1/2]

template<class InputIt >
void jkqtpstat5NumberStatistics ( InputIt  first,
InputIt  last,
double *  minimum,
double  minimumQuantile = 0,
double *  median = nullptr,
double *  maximum = nullptr,
double  maximumQuantile = 1,
double  quantile1Spec = 0.25,
double *  quantile1 = nullptr,
double  quantile2Spec = 0.75,
double *  quantile2 = nullptr,
double *  IQR = nullptr,
double *  IQRSignificance = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the Five-Number Statistical Summary (minimum, median, maximum and two user-defined quantiles (as well as derived from these the inter quartile range)) of a given data range first ... last (5-value statistics, e.g. used for boxplots)

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]minimumoptionally returns the minimum value of the array
minimumQuantilespecifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!
[out]medianoptionally returns the median value of the array
[out]maximumoptionally returns the maximum value of the array
maximumQuantilespecifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!
quantile1Specspecifies which quantile to calculate for qantile1 (range: 0..1)
[out]quantile1optionally returns the first quantile of the array (specified by quantile1Spec )
quantile2Specspecifies which quantile to calculate for qantile2 (range: 0..1)
[out]quantile2optionally returns the second quantile of the array (specified by quantile2Spec )
[out]IQRinterquartile range, i.e. the range between quantile1 and quantile2
[out]IQRSignificancesignificance range of the interquartile range, calculated as

\[ 2\cdot\frac{1.58\cdot \mbox{IQR}}{\sqrt{N}} \]

See also
https://en.wikipedia.org/wiki/Box_plot
Parameters
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Note
This operation implies an internal copy of the data, as well as sorting it!
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.
See also
https://en.wikipedia.org/wiki/Five-number_summary, jkqtpstatAddVBoxplotAndOutliers, jkqtpstatAddHBoxplotAndOutliers, jkqtpstatAddVBoxplot, jkqtpstatAddHBoxplot, Tutorial (JKQTPDatastore): Advanced 1-Dimensional Statistics with JKQTPDatastore

◆ jkqtpstat5NumberStatistics() [2/2]

template<class InputIt >
JKQTPStat5NumberStatistics jkqtpstat5NumberStatistics ( InputIt  first,
InputIt  last,
double  quantile1Spec = 0.25,
double  quantile2Spec = 0.75,
double  minimumQuantile = 0,
double  maximumQuantile = 1.0 
)
inline

calculates the Five-Number Statistical Summary (minimum, median, maximum and two user-defined quantiles (as well as derived from these the inter quartile range)) of a given data range first ... last (5-value statistics, e.g. used for boxplots)

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
quantile1Specspecifies which quantile to calculate for qantile1 (range: 0..1)
quantile2Specspecifies which quantile to calculate for qantile2 (range: 0..1)
minimumQuantilespecifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
maximumQuantilespecifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
Returns
the Five-Number Statistical Summary in a JKQTPStat5NumberStatistics
Note
This operation implies an internal copy of the data, as well as sorting it!
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.
See also
https://en.wikipedia.org/wiki/Five-number_summary, jkqtpstatAddVBoxplotAndOutliers, jkqtpstatAddHBoxplotAndOutliers, jkqtpstatAddVBoxplot, jkqtpstatAddHBoxplot, Tutorial (JKQTPDatastore): Advanced 1-Dimensional Statistics with JKQTPDatastore

◆ jkqtpstat5NumberStatisticsAndOutliers()

template<class InputIt , class OutputIt >
void jkqtpstat5NumberStatisticsAndOutliers ( InputIt  first,
InputIt  last,
OutputIt  outliersout,
double *  minimum = nullptr,
double  minimumQuantile = 0,
double *  median = nullptr,
double *  maximum = nullptr,
double  maximumQuantile = 1,
double *  quantile1 = nullptr,
double  quantile1Spec = 0.25,
double *  quantile2 = nullptr,
double  quantile2Spec = 0.75,
double *  IQR = nullptr,
double *  IQRSignificance = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the Five-Number Statistical Summary (minimum, median, maximum and two user-defined quantiles (as well as derived from these the inter quartile range)) of a given data range first ... last (5-value statistics, e.g. used for boxplots)

Template Parameters
InputItstandard iterator type of first and last.
OutputItstandard output iterator type used for the outliers output outliersout, use e.g. std::back_inserter
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
outliersoutoutput iterator that receives the outliers, smaller than minimum and larger than maximum
[out]minimumoptionally returns the minimum value of the array
minimumQuantilespecifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
[out]medianoptionally returns the median value of the array
[out]maximumoptionally returns the maximum value of the array
maximumQuantilespecifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
quantile1Specspecifies which quantile to calculate for qantile1 (range: 0..1)
[out]quantile1optionally returns the first quantile of the array (specified by quantile1Spec )
quantile2Specspecifies which quantile to calculate for qantile2 (range: 0..1)
[out]quantile2optionally returns the second quantile of the array (specified by quantile2Spec )
[out]IQRinterquartile range, i.e. the range between quantile1 and quantile2
[out]IQRSignificancesignificance range of the interquartile range, calculated as

\[ 2\cdot\frac{1.58\cdot \mbox{IQR}}{\sqrt{N}} \]

See also
https://en.wikipedia.org/wiki/Box_plot
Parameters
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Note
This operation implies an internal copy of the data, as well as sorting it!
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.
See also
https://en.wikipedia.org/wiki/Five-number_summary, jkqtpstatAddVBoxplotAndOutliers, jkqtpstatAddHBoxplotAndOutliers, jkqtpstatAddVBoxplot, jkqtpstatAddHBoxplot, Tutorial (JKQTPDatastore): Advanced 1-Dimensional Statistics with JKQTPDatastore

◆ jkqtpstat5NumberStatisticsAndOutliersOfSortedVector()

template<class TVector , class OutputIt >
void jkqtpstat5NumberStatisticsAndOutliersOfSortedVector ( const TVector &  data,
OutputIt  outliersout,
double *  minimum = nullptr,
double  minimumQuantile = 0,
double *  median = nullptr,
double *  maximum = nullptr,
double  maximumQuantile = 1,
double *  quantile1 = nullptr,
double  quantile1Spec = 0.25,
double *  quantile2 = nullptr,
double  quantile2Spec = 0.75,
double *  IQR = nullptr,
double *  IQRSignificance = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the Five-Number Statistical Summary (minimum, median, maximum and two user-defined quantiles (as well as derived from these the inter quartile range)) of a sorted vector

Template Parameters
TVectora type, compatible with std::vector (i,e, providing size(), []-element access and iterators)
Parameters
dataa sorted vector with values
outliersoutoutput iterator that receives the outliers, smaller than minimum and larger than maximum
[out]minimumoptionally returns the minimum value of the array
minimumQuantilespecifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!)
[out]medianoptionally returns the median value of the array
[out]maximumoptionally returns the maximum value of the array
maximumQuantilespecifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!)
quantile1Specspecifies which quantile to calculate for qantile1 (range: 0..1)
[out]quantile1optionally returns the first quantile of the array (specified by quantile1Spec )
quantile2Specspecifies which quantile to calculate for qantile2 (range: 0..1)
[out]quantile2optionally returns the second quantile of the array (specified by quantile2Spec )
[out]IQRinterquartile range, i.e. the range between quantile1 and quantile2
[out]IQRSignificancesignificance range of the interquartile range, calculated as

\[ 2\cdot\frac{1.58\cdot \mbox{IQR}}{\sqrt{N}} \]

See also
https://en.wikipedia.org/wiki/Box_plot
Parameters
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Note
This operation implies an internal copy of the data, as well as sorting it!
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.
See also
https://en.wikipedia.org/wiki/Five-number_summary, jkqtpstatAddVBoxplotAndOutliers, jkqtpstatAddHBoxplotAndOutliers, jkqtpstatAddVBoxplot, jkqtpstatAddHBoxplot, Tutorial (JKQTPDatastore): Advanced 1-Dimensional Statistics with JKQTPDatastore

◆ jkqtpstat5NumberStatisticsOfSortedVector()

template<class TVector >
void jkqtpstat5NumberStatisticsOfSortedVector ( const TVector &  data,
double *  minimum = nullptr,
double  minimumQuantile = 0,
double *  median = nullptr,
double *  maximum = nullptr,
double  maximumQuantile = 1,
double *  quantile1 = nullptr,
double  quantile1Spec = 0.25,
double *  quantile2 = nullptr,
double  quantile2Spec = 0.75,
double *  IQR = nullptr,
double *  IQRSignificance = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the Five-Number Statistical Summary (minimum, median, maximum and two user-defined quantiles (as well as derived from these the inter quartile range)) of a sorted vector

Template Parameters
TVectora type, compatible with std::vector (i,e, providing size(), []-element access and iterators)
Parameters
dataa sorted vector with values
[out]minimumoptionally returns the minimum value of the array
minimumQuantilespecifies a quantile for the return value minimum (default is 0 for the real minimum, but you could e.g. use 0.05 for the 5% quantile!
[out]medianoptionally returns the median value of the array
[out]maximumoptionally returns the maximum value of the array
maximumQuantilespecifies a quantile for the return value maximum (default is 1 for the real maximum, but you could e.g. use 0.95 for the 95% quantile!
quantile1Specspecifies which quantile to calculate for qantile1 (range: 0..1)
[out]quantile1optionally returns the first quantile of the array (specified by quantile1Spec )
quantile2Specspecifies which quantile to calculate for qantile2 (range: 0..1)
[out]quantile2optionally returns the second quantile of the array (specified by quantile2Spec )
[out]IQRinterquartile range, i.e. the range between quantile1 and quantile2
[out]IQRSignificancesignificance range of the interquartile range, calculated as

\[ 2\cdot\frac{1.58\cdot \mbox{IQR}}{\sqrt{N}} \]

See also
https://en.wikipedia.org/wiki/Box_plot
Parameters
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Note
This operation implies an internal copy of the data, as well as sorting it!
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.
See also
https://en.wikipedia.org/wiki/Five-number_summary, jkqtpstatAddVBoxplotAndOutliers, jkqtpstatAddHBoxplotAndOutliers, jkqtpstatAddVBoxplot, jkqtpstatAddHBoxplot, Tutorial (JKQTPDatastore): Advanced 1-Dimensional Statistics with JKQTPDatastore

◆ jkqtpstatAverage()

template<class InputIt >
double jkqtpstatAverage ( InputIt  first,
InputIt  last,
size_t *  Noutput = nullptr 
)
inline

calculates the average of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
Average of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, NAN is returned

This function implements:

\[ \overline{X}=\frac{1}{N}\cdot\sum\limits_{i=1}^{N}X_i \]

Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatCentralMoment()

template<class InputIt >
double jkqtpstatCentralMoment ( InputIt  first,
InputIt  last,
int  order,
double *  averageOut = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the given central moment $ \langle (X-\mu)^o\rangle $ of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
orderoder $ o $ of the central moment $ \langle (X-\mu)^o\rangle $
[out]averageOutreturns (optionally) the average of the dataset
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
the given central moment $ \langle (X-\mu)^o\rangle $ of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, 0 is returned

This function implements:

\[ \langle (X-\mu)^o\rangle= \mathbb{E}\left[\left(X-\mu\right)^o\right] \]

where $\mu$ is the mean of a random variable $X$ and $\overline{x}$ is the average (calculated using jkqtpstatAverage() ) of the input dataset $ x_i$.

Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatCorrelationCoefficient()

template<class InputIt1 , class InputIt2 >
double jkqtpstatCorrelationCoefficient ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
double *  averageOut1 = nullptr,
double *  averageOut2 = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculate empirical (Pearson's) correlation coefficient $ \rho_{x,y} $ between two given data ranges first1 ... last1 and first2 ... last2

Template Parameters
InputIt1standard iterator type of first1 and last1.
InputIt2standard iterator type of first2 and last2.
Parameters
first1iterator pointing to the first item in the first dataset to use $ X_1 $
last1iterator pointing behind the last item in the first dataset to use $ X_N $
first2iterator pointing to the second item in the first dataset to use $ Y_1 $
[out]averageOut1returns (optionally) the average of the first dataset $ X_i $
[out]averageOut2returns (optionally) the average of the second dataset $ Y_i $
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
pearson's correlation coefficient If the given range first1 ... last1 is empty, JKQTP_DOUBLE_NAN is returned

This function implements:

\[ \rho_{x,y}=\text{CorCoeff}_{\text{Pearson}}(x,y)=\frac{\sum\limits_{i=0}^{N-1}(x_i-\overline{x})(y_i-\overline{y})}{\sqrt{\sum\limits_{i=0}^{N-1}(x_i-\overline{x})^2\cdot\sum\limits_{i=0}^{N-1}(y_i-\overline{y})^2}} \]

Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.
See also
https://en.wikipedia.org/wiki/Pearson_correlation_coefficient

◆ jkqtpstatCount()

template<class InputIt >
size_t jkqtpstatCount ( InputIt  first,
InputIt  last 
)
inline

calculates the number of valid values in the given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
Returns
number of valid values between first and last (excluding invalid doubles).
Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatCumSum()

template<class InputIt , class OutputIt >
void jkqtpstatCumSum ( InputIt  first,
InputIt  last,
OutputIt  output 
)
inline

calculates the vector of cummulative (or partial) sums of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
OutputItstandard output iterator type
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]outputThis iterator is used to store the results, use e.g. a std::back_inserter Output is then a vector of cummulative (or partial) sums returned between first and last (excluding invalid doubles). For invalid values, the last sum is re-inserted, so the returned vector has the same number of entries as the range first ... last

This function implements:

\[ \sum(X)_j=\cdot\sum\limits_{i=1}^{j}X_i \]

Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatFilterGoodFloat()

template<class InputIt , class OutputIt >
size_t jkqtpstatFilterGoodFloat ( InputIt  first,
InputIt  last,
OutputIt  output 
)
inline

filters the given data range first ... last for good floats (using JKQTPIsOKFloat() )

Template Parameters
InputItstandard iterator type of first and last.
OutputItstandard output iterator type
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]outputThis iterator is used to store the results, use e.g. a std::back_inserter
Returns
number of elementes put into output
Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatMAD()

template<class InputIt >
double jkqtpstatMAD ( InputIt  first,
InputIt  last,
double *  median = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the median absolute deviation about the median (MAD) of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]medianoptionally returns the median value in this variable
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
the median absolute deviation about the median (MAD) of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, NAN is returned

This function calculates

\[ \mbox{MAD}(\vec{x})=\mbox{Med}\left\{|\vec{x}-\mbox{Med}(\vec{x})|\right\} \]

Note
This operation implies an internal copy of the data, as well as sorting it!
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.
See also
https://en.wikipedia.org/wiki/Median_absolute_deviation and Ricardo A. Maronna, R. Douglas Martin, Victor J. Yohai: "Robust Statistics: Theory and Methods", Wiley, 2006, ISBN: 978-0-470-01092-1

◆ jkqtpstatMaximum()

template<class InputIt >
double jkqtpstatMaximum ( InputIt  first,
InputIt  last,
InputIt *  maxPos = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the maximum value in the given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]maxPosreceives the location of the maximum element value
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
the maximum value from the given range
Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatMedian()

template<class InputIt >
double jkqtpstatMedian ( InputIt  first,
InputIt  last,
size_t *  Noutput = nullptr 
)
inline

calculates the median of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
the median of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, NAN is returned
Note
This operation implies an internal copy of the data, and then uses std::nth_element() to calculate the median in linear time O(N)!
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatMedianAndPartialSort()

template<class InputIt >
double jkqtpstatMedianAndPartialSort ( InputIt  first,
InputIt  last 
)
inline

calculates the median of a given data range first ... last, this version partially sorts the range (i.e. no internal copy and checking for NAN-values is performed!)

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
Returns
the median of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, NAN is returned
Note
This operation implies uses std::nth_element() to calculate the median in linear time O(N)! The given range is partially sorted after the call!

◆ jkqtpstatMedianOfSortedVector()

template<class TVector >
double jkqtpstatMedianOfSortedVector ( const TVector &  data,
size_t *  Noutput = nullptr 
)
inline

calculates the median of a given sorted (!) data vector

Template Parameters
TVectora type, compatible with std::vector (i,e, providing size(), []-element access and iterators)
Parameters
dataa sorted vector with values
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
the median of data If data is empty, NAN is returned

◆ jkqtpstatMinimum()

template<class InputIt >
double jkqtpstatMinimum ( InputIt  first,
InputIt  last,
InputIt *  minPos = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the minimum value in the given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]minPosreceives the location of the minimum element value
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
the minimum value from the given range
Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatMinMax()

template<class InputIt >
void jkqtpstatMinMax ( InputIt  first,
InputIt  last,
double &  min,
double &  max,
InputIt *  minPos = nullptr,
InputIt *  maxPos = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the minimum and maximum values in the given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]minreceives the minimum element value
[out]maxreceives the maximum element value
[out]minPosreceives the location of the minimum element value
[out]maxPosreceives the location of the minimum maximum element value
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatModifiedSum()

template<class InputIt , class FF >
double jkqtpstatModifiedSum ( InputIt  first,
InputIt  last,
FF  modifierFunctor,
size_t *  Noutput = nullptr 
)
inline

calculates the sum of a given data range first ... last of values, modifying each value with a given functor modifierFunctor before accumulating

Template Parameters
InputItstandard iterator type of first and last.
FFa functor type
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
modifierFunctorthe function to apply to each element in the range before summation (of type FF )
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
Sum of modified data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, 0 is returned

This function implements:

\[ \sum(X)=\cdot\sum\limits_{i=1}^{N}\mbox{modifierFunctor}(X_i) \]

This function allows to e.g. calculate the sum of squares by calling

jkqtpstatModifiedSum(first, last, [](double v) { return v*v; });
jkqtpstatModifiedSum(first, last, &jkqtp_sqr<double>);
double jkqtpstatModifiedSum(InputIt first, InputIt last, FF modifierFunctor, size_t *Noutput=nullptr)
calculates the sum of a given data range first ... last of values, modifying each value with a given ...
Definition jkqtpstatbasics.h:320
Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatMoment()

template<class InputIt >
double jkqtpstatMoment ( InputIt  first,
InputIt  last,
int  order,
size_t *  Noutput = nullptr 
)
inline

calculates the given (non-central) moment $ \langle X^o\rangle $ of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
orderoder $ o $ of the central moment $ \langle X^o\rangle $
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
the given moment $ \langle X^o\rangle $ of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, 0 is returned

This function implements:

\[ \langle X^n\rangle= \mathbb{E}\left[X^n\right] \]

where $\mu$ is the mean of a random variable $X$ and $\overline{x}$ is the average (calculated using jkqtpstatAverage() ) of the input dataset $ x_i$.

Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatNMAD()

template<class InputIt >
double jkqtpstatNMAD ( InputIt  first,
InputIt  last,
double *  median = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the normalized median absolute deviation about the median (NMAD) of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]medianoptionally returns the median value in this variable
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
the normalized median absolute deviation about the median (NMAD) of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, NAN is returned

This function calculates

\[ \mbox{NMAD}(\vec{x})=\frac{\mbox{MAD}(\vec{x})}{0.6745}=\frac{\mbox{Med}\left\{|\vec{x}-\mbox{Med}(\vec{x})|\right\}}{0.6745} \]

Note
This operation implies an internal copy of the data, as well as sorting it!
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.
See also
https://en.wikipedia.org/wiki/Median_absolute_deviation and Ricardo A. Maronna, R. Douglas Martin, Victor J. Yohai: "Robust Statistics: Theory and Methods", Wiley, 2006, ISBN: 978-0-470-01092-1

◆ jkqtpstatQuantile()

template<class InputIt >
double jkqtpstatQuantile ( InputIt  first,
InputIt  last,
double  quantile,
size_t *  Noutput = nullptr 
)
inline

calculates the quantile -th quantile of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
quantilethe given quantile, range 0..1 (e.g. 0.25 for the 25% quartile ...)
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
the quantile -th quantile of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, NAN is returned
Note
This operation implies an internal copy of the data, as well as sorting it!
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatSkewness()

template<class InputIt >
double jkqtpstatSkewness ( InputIt  first,
InputIt  last,
double *  averageOut = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the skewness $ \gamma_1=\mathbb{E}\left[\left(\frac{X-\mu}{\sigma}\right)^3\right] $ of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]averageOutreturns (optionally) the average of the dataset
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
skewness $ \gamma_1 $ of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, 0 is returned

This function implements:

\[ \gamma_1=\mathbb{E}\left[\left(\frac{X-\mu}{\sigma}\right)^3\right]= \frac{m_3}{m_2^{3/2}}  = \frac{\frac{1}{n} \sum_{i=1}^n (x_i-\overline{x})^3}{\left(\frac{1}{n} \sum_{i=1}^n (x_i-\overline{x})^2\right)^{3/2}} \]

where $\mu$ is the mean and $\sigma$ the standard deviation of a random variable $X$ and $\overline{x}$ is the average (calculated using jkqtpstatAverage() ) of the input dataset $ x_i$.

Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatStdDev()

template<class InputIt >
double jkqtpstatStdDev ( InputIt  first,
InputIt  last,
double *  averageOut = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the standard deviation $ \sigma_X=\sqrt{\mbox{Var}(X)} $ of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]averageOutreturns (optionally) the average of the dataset
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
standard deviation of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, 0 is returned

This function implements:

\[ \sigma_X=\sqrt{\frac{1}{N-1}\cdot\sum\limits_{i=1}^{N}(X_i-\overline{X})^2}= \]

Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatSum()

template<class InputIt >
double jkqtpstatSum ( InputIt  first,
InputIt  last,
size_t *  Noutput = nullptr 
)
inline

calculates the sum of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
Sum of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, 0 is returned

This function implements:

\[ \sum(X)=\cdot\sum\limits_{i=1}^{N}X_i \]

Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatSumSqr()

template<class InputIt >
double jkqtpstatSumSqr ( InputIt  first,
InputIt  last,
size_t *  Noutput = nullptr 
)
inline

calculates the sum of squares of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
Sum of squares of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, 0 is returned

This function implements:

\[ \sum(X)=\cdot\sum\limits_{i=1}^{N}X_i^2 \]

Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatVariance()

template<class InputIt >
double jkqtpstatVariance ( InputIt  first,
InputIt  last,
double *  averageOut = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the variance $ \sigma_X^2=\mbox{Var}(X) $ of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
InputWeightItstandard iterator type of firstWeight
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
[out]averageOutreturns (optionally) the average of the dataset
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
Variance of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, 0 is returned

This function implements:

\[ \sigma_X^2=\text{Var}(X)=\frac{1}{N-1}\cdot\sum\limits_{i=1}^{N}(X_i-\overline{X})^2=\frac{1}{N-1}\cdot\left(\sum_{i=1}^NX_i^2-\frac{1}{N}\cdot\left(\sum_{i=1}^NX_i\right)^2\right) \]

Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatWeightedAverage()

template<class InputIt , class InputWeightIt >
double jkqtpstatWeightedAverage ( InputIt  first,
InputIt  last,
InputWeightIt  firstWeight,
size_t *  Noutput = nullptr 
)
inline

calculates the weighted average of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
InputWeightItstandard iterator type of firstWeight
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
firstWeightiterator pointing to the first item in the weights dataset $ w_i $
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
weighted average of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, NAN is returned

This function implements:

\[ \overline{X}=\frac{\sum\limits_{i=1}^{N}w_i\cdot X_i}{\sum\limits_{i=1}^{N}w_i} \]

Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatWeightedStdDev()

template<class InputIt , class InputWeightIt >
double jkqtpstatWeightedStdDev ( InputIt  first,
InputIt  last,
InputWeightIt  firstWeight,
double *  averageOut = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the weighted standard deviation $ \sigma_X=\sqrt{\mbox{Var}(X)} $ of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
InputWeightItstandard iterator type of firstWeight
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
firstWeightiterator pointing to the first item in the weights dataset $ w_i $
[out]averageOutreturns (optionally) the average of the dataset
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
weighted standard deviation of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, 0 is returned

This function implements:

\[ \sigma_v=\sqrt{\frac{\sum\limits_{i=1}^{N}w_i\cdot (v_i-\overline{v})^2}{\sum\limits_{i=1}^{N}w_i}} \]

Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.

◆ jkqtpstatWeightedVariance()

template<class InputIt , class InputWeightIt >
double jkqtpstatWeightedVariance ( InputIt  first,
InputIt  last,
InputWeightIt  firstWeight,
double *  averageOut = nullptr,
size_t *  Noutput = nullptr 
)
inline

calculates the weighted variance $ \sigma_X^2=\mbox{Var}(X) $ of a given data range first ... last

Template Parameters
InputItstandard iterator type of first and last.
InputWeightItstandard iterator type of firstWeight
Parameters
firstiterator pointing to the first item in the dataset to use $ X_1 $
lastiterator pointing behind the last item in the dataset to use $ X_N $
firstWeightiterator pointing to the first item in the weights dataset $ w_i $
[out]averageOutreturns (optionally) the average of the dataset
[out]Noutputoptionally returns the number of accumulated valid values in this variable
Returns
weighted standard deviation of the data returned between first and last (excluding invalid doubles). If the given range first ... last is empty, 0 is returned

This function implements:

\[ \sigma_v^2=\text{Var}(v)=\frac{\sum\limits_{i=1}^{N}w_i\cdot (v_i-\overline{v})^2}{\sum\limits_{i=1}^{N}w_i} \]

Note
Each value is the specified range is converted to a double using jkqtp_todouble(). Entries in the range that are invalid double (using JKQTPIsOKFloat() ) are ignored when calculating.