Correlation¶

gsl_stats_correlation(data1, data2)

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) \over \hat{\sigma_x} \hat{\sigma_y}} = {{1 \over n-1} \sum (x_i - \hat{x}) (y_i - \hat{y}) \over \sqrt{{1 \over n-1} \sum (x_i - {\hat{x}})^2} \sqrt{{1 \over n-1} \sum (y_i - {\hat{y}})^2} }$
gsl_stats_spearman(data1, data2)

This function computes the Spearman rank correlation coefficient between the datasets data1 and data2 which must both be of the same length n. The Spearman rank correlation between vectors $$x$$ and $$y$$ is equivalent to the Pearson correlation between the ranked vectors $$x_R$$ and $$y_R$$, where ranks are defined to be the average of the positions of an element in the ascending order of the values.