Go to the first, previous, next, last section, table of contents.

Mean, Standard Deviation and Variance

Statistics: double gsl_stats_mean (const double data[], size_t stride, size_t n)
This function returns the arithmetic mean of data, a dataset of length n with stride stride. The arithmetic mean, or sample mean, is denoted by @math{\Hat\mu} and defined as,

where @math{x_i} are the elements of the dataset data. For samples drawn from a gaussian distribution the variance of @math{\Hat\mu} is @math{\sigma^2 / N}.

Statistics: double gsl_stats_variance (const double data[], size_t stride, size_t n)
This function returns the estimated, or sample, variance of data, a dataset of length n with stride stride. The estimated variance is denoted by @math{\Hat\sigma^2} and is defined by,

where @math{x_i} are the elements of the dataset data. Note that the normalization factor of @math{1/(N-1)} results from the derivation of @math{\Hat\sigma^2} as an unbiased estimator of the population variance @math{\sigma^2}. For samples drawn from a gaussian distribution the variance of @math{\Hat\sigma^2} itself is @math{2 \sigma^4 / N}.

This function computes the mean via a call to gsl_stats_mean. If you have already computed the mean then you can pass it directly to gsl_stats_variance_m.

Statistics: double gsl_stats_variance_m (const double data[], size_t stride, size_t n, double mean)
This function returns the sample variance of data relative to the given value of mean. The function is computed with @math{\Hat\mu} replaced by the value of mean that you supply,

Statistics: double gsl_stats_sd (const double data[], size_t stride, size_t n)
Statistics: double gsl_stats_sd_m (const double data[], size_t stride, size_t n, double mean)
The standard deviation is defined as the square root of the variance. These functions return the square root of the corresponding variance functions above.

Statistics: double gsl_stats_variance_with_fixed_mean (const double data[], size_t stride, size_t n, double mean)
This function computes an unbiased estimate of the variance of data when the population mean mean of the underlying distribution is known a priori. In this case the estimator for the variance uses the factor @math{1/N} and the sample mean @math{\Hat\mu} is replaced by the known population mean @math{\mu},

Statistics: double gsl_stats_sd_with_fixed_mean (const double data[], size_t stride, size_t n, double mean)
This function calculates the standard deviation of data for a a fixed population mean mean. The result is the square root of the corresponding variance function.


Go to the first, previous, next, last section, table of contents.