variance

Function variance 

Source
pub fn variance(data: &[f64]) -> Option<f64>
Expand description

Returns the sample variance of values in the slice.

Uses Bessel’s correction (divides by n-1). Returns None if the slice has fewer than 2 elements.

§Example

use d3rs::array::variance;

let data = vec![2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0];
let var = variance(&data).unwrap();
assert!((var - 4.571428571428571).abs() < 1e-10);