Sample correlation coefficient
The correlation coefficient of two variables in a data set equals to their covariance divided by the product of their individual standard deviations. It is a normalized measurement of how the two are linearly related.
The correlation r between two variables is:
\[r= \frac{1}{n-1}\sum \frac{\left (\left ( X_{i}-x \right ) \left ( Y_{i}-y \right )\right )}{s_{x}s_{y}} \]
where n is the number of observations in the sample, Σ is the summation symbol, xi is the x value for observation i, x is the sample mean of x, yi is the y value for observation i, y is the sample mean of y, sx is the sample standard deviation of x, and sy is the sample standard deviation of y.
for our calculation let the value of sx= a and sy=b Xi=X and Yi= Y