Function rgsl::statistics::variance
[−]
[src]
pub fn variance(data: &[f64], stride: usize, n: usize) -> f64
This function returns the estimated, or sample, variance of data, a dataset of length n with stride stride. The estimated variance is denoted by \Hat\sigma2 and is defined by,
\Hat\sigma2 = (1/(N-1)) \sum (x_i - \Hat\mu)2
where x_i are the elements of the dataset data. Note that the normalization factor of 1/(N-1) results from the derivation of \Hat\sigma2 as an unbiased estimator of the population variance \sigma2. For samples drawn from a Gaussian distribution the variance of \Hat\sigma2 itself is 2 \sigma4 / 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.