Function rgsl::statistics::correlation [] [src]

pub fn correlation(data1: &[f64], stride1: usize, data2: &[f64], stride2: usize, n: usize) -> f64

This function efficiently computes the Pearson correlation coefficient between the datasets data1 and data2 which must both be of the same length n.

r = cov(x, y) / (\Hat\sigma_x \Hat\sigma_y) = {1/(n-1) \sum (x_i - \Hat x) (y_i - \Hat y) \over \sqrt{1/(n-1) \sum (x_i - \Hat x)2} \sqrt{1/(n-1) \sum (y_i - \Hat y)2} }