Theoretica
A C++ numerical and automatic mathematical library
statistics.h File Reference

Statistical functions. More...

Go to the source code of this file.

Namespaces

 theoretica
 Main namespace of the library which contains all functions and objects.
 
 theoretica::stats
 Statistical functions.
 

Functions

template<typename Dataset >
real theoretica::stats::mean (const Dataset &X)
 Compute the mean of a dataset. More...
 
template<typename Dataset >
real theoretica::stats::range (const Dataset &X)
 Computes the range of a data set, defined as \(x_{max} - {x_min}\). More...
 
template<typename Dataset >
real theoretica::stats::semidispersion (const Dataset &X)
 Computes the maximum semidispersion of a data set defined as \((x_{max} - {x_min}) / 2\). More...
 
template<typename Dataset >
real theoretica::stats::propagate_sum (const Dataset &sigma)
 Propagate the error over a sum of random variables under quadrature, as \(\sqrt{\sum_{i = 1}^n \sigma_i^2}\), where each \(\sigma_i\) corresponds to the standard deviation of a variable. More...
 
template<typename Dataset1 , typename Dataset2 >
real theoretica::stats::propagate_product (const Dataset1 &sigma, const Dataset2 &mean)
 Propagate the error over a product of random variables under quadrature, as \(\sqrt{\sum_{i = 1}} (\sigma_i / \mu_i)^2}\), where each \(\sigma_i\) corresponds to the standard deviation of a variable. More...
 
template<typename Dataset >
real theoretica::stats::total_sum_squares (const Dataset &X)
 Compute the total sum of squares (TSS) of a given dataset as \(sum(square(x_i - x_{mean}))\) using Welford's one-pass method. More...
 
template<typename Dataset >
real theoretica::stats::variance (const Dataset &X, unsigned int constraints=1)
 Compute the variance given a dataset and the number of constraints. More...
 
template<typename Dataset >
void theoretica::stats::moments2 (const Dataset &X, real &out_mean, real &out_variance, unsigned int constraints=1)
 Compute the mean and the variance of a dataset in a single pass, using Welford's method, with the given number of constraints (defaults to 1 for Bessel's correction). More...
 
template<typename Dataset >
real theoretica::stats::stdev (const Dataset &data, unsigned int constraints=1)
 Compute the standard deviation given a dataset and the number of constraints. More...
 
template<typename Dataset >
real theoretica::stats::stdom (const Dataset &X)
 Compute the standard deviation of the mean given a dataset. More...
 
template<typename Dataset >
real theoretica::stats::standard_relative_error (const Dataset &X)
 Compute the relative error on a dataset using estimates of its mean and standard deviation, with the given number of constraints (defaults to 1 for Bessel's correction). More...
 
template<typename Dataset1 , typename Dataset2 >
real theoretica::stats::covariance (const Dataset1 &X, const Dataset2 &Y, unsigned int constraints=1)
 Compute the covariance between two datasets with the given number of constraints. More...
 
template<typename Dataset1 , typename Dataset2 >
real theoretica::stats::correlation_coefficient (const Dataset1 &X, const Dataset2 &Y)
 Compute Pearson's correlation coefficient R between two datasets. More...
 
template<typename Dataset >
real theoretica::stats::autocorrelation (const Dataset &X, unsigned int n=1)
 Compute the lag-n autocorrelation of a dataset as \(\). More...
 
template<typename Dataset >
real theoretica::stats::absolute_deviation (const Dataset &X)
 Compute the mean absolute deviation of a dataset as \(\frac{\sum_{i = 1}^n |x_i - \hat \mu|}{n}\). More...
 
template<typename Dataset >
real theoretica::stats::skewness (const Dataset &X)
 Compute the skewness of a dataset as \(\frac{\sum_{i=1}^n (\frac{x_i - \hat \mu}{\hat \sigma})^3}{n}\). More...
 
template<typename Dataset >
real theoretica::stats::kurtosis (const Dataset &X)
 Compute the normalized kurtosis of a dataset as \(\frac{\sum_{i=1}^n (\frac{x_i - \hat \mu}{\hat \sigma})^4}{n} - 3\). More...
 
template<typename RealFunction >
real theoretica::stats::gaussian_expectation (RealFunction g, real mean, real sigma)
 Compute the expectation value of a given function with respect to a Gaussian distribution with the given parameters. More...
 
real theoretica::stats::z_score (real x, real mean, real sigma)
 Compute the Z-score of an observed value with respect to a Gaussian distribution with the given parameters. More...
 
template<typename Dataset >
Dataset theoretica::stats::normalize_z_score (const Dataset &X)
 Normalize a data set using Z-score normalization. More...
 
template<typename Dataset1 , typename Dataset2 , typename Dataset3 >
real theoretica::stats::chi_square (const Dataset1 &O, const Dataset2 &E, const Dataset3 &sigma)
 Compute the chi-square from the set of observed quantities, expected quantities and errors. More...
 
real theoretica::stats::pvalue_chi_squared (real chi_sqr, unsigned int ndf)
 Compute the (right-tailed) p-value associated to a computed Chi-square value as the integral of the Chi-squared distribution from the given value to infinity (right-tailed). More...
 
template<typename Dataset1 , typename Dataset2 , typename Dataset3 >
real theoretica::stats::chi_square_linear (const Dataset1 &X, const Dataset2 &Y, const Dataset3 &sigma, real intercept, real slope)
 Compute the chi-square on a linear regression, as the sum of the squares of the residuals divided by the standard deviation. More...
 
template<typename Dataset1 , typename Dataset2 , typename Dataset3 >
real theoretica::stats::reduced_chi_square_linear (const Dataset1 &X, const Dataset2 &Y, const Dataset3 &sigma, real intercept, real slope)
 Compute the reduced chi-squared on a linear regression, computed as the usual chi-square (computed by chi_square_linear) divided by the number of degrees of freedom of the model ( \(N - 2\)). More...
 

Detailed Description

Statistical functions.