Ten days of statistics (8) - Correlationship
Covariance
This is a measure of how two random variables and change together. Formally
Where
- is the mean of
- is the mean of
Pearson correlation coefficient
The Pearson correlation coefficient is given by:
Where
- is the standard deviation of
- is the standard deviation of
Spearman’s rank correlation coefficient
Given 2 random variables and with the same sample size. Let and denotes the ranks of each data point on and respectively. Let is the Spearman’s rank correlation coefficient of and , which equal to the Pearson correlation coefficient of and
If X and Y contains no duplicates
Practice
Hackerrank has some exercises for you to test your knowledge:
- https://www.hackerrank.com/challenges/s10-pearson-correlation-coefficient/problem
- https://www.hackerrank.com/challenges/s10-spearman-rank-correlation-coefficient/problem
Next lesson: Linear regression