Function lattice_qcd_rs::statistics::covariance
source · pub fn covariance<'a, 'b, T, IntoIter1, IntoIter2>(
data_1: IntoIter1,
data_2: IntoIter2
) -> Option<T>where
T: 'a + 'b + Div<f64, Output = T> + for<'c> Sum<&'c T> + Sum<T> + Mul<T, Output = T> + Clone + Sub<T, Output = T>,
IntoIter1: IntoIterator<Item = &'a T> + Clone,
IntoIter1::IntoIter: ExactSizeIterator,
IntoIter2: IntoIterator<Item = &'b T> + Clone,
IntoIter2::IntoIter: ExactSizeIterator,
Expand description
compute the covariance between two slices.
Return None
if the slices are not of the same length
Example
use lattice_qcd_rs::statistics::covariance;
use nalgebra::Complex;
let vec = vec![1_f64, 2_f64, 3_f64, 4_f64];
let array = [1_f64, 2_f64, 3_f64, 4_f64];
let cov = covariance(&array, &vec);
assert!(cov.is_some());
let array_complex = [Complex::new(1_f64, 2_f64), Complex::new(-7_f64, -9_f64)];
let vec_complex = vec![Complex::new(1_f64, 2_f64), Complex::new(-7_f64, -9_f64)];
let cov = covariance(&vec_complex, &array_complex);
assert!(cov.is_some());
assert!(covariance(&[], &[1_f64]).is_none());