Correlation helpers for f64 slices.
The crate provides a population covariance helper and a Pearson correlation helper for paired slices of equal length.
Examples
use ;
let x = ;
let y = ;
assert_eq!;
assert!;
Correlation helpers for f64 slices.
The crate provides a population covariance helper and a Pearson correlation helper for paired slices of equal length.
use use_correlation::{covariance, pearson_correlation};
let x = [1.0, 2.0, 3.0, 4.0, 5.0];
let y = [2.0, 4.0, 6.0, 8.0, 10.0];
assert_eq!(covariance(&x, &y).unwrap(), 4.0);
assert!((pearson_correlation(&x, &y).unwrap() - 1.0).abs() < 1.0e-12);