# Correlation between two datasets

I have two datasets having values : s1 = [25 ,75, 25, 75, 25, 75, 25, 75, 25, 75] and s2 = [46.24, 73.16, 27.13, 74.30, 25, 72.52, 53.15, 75, 40.15, 69.86]

Pearson correlation coefficient = 0.90 and Spearman correlation coefficient = 0.90 (calculated using python library)

How correlation coefficient is 0.90, because for it to be 0.90 as per my understanding s1 and should be :
s1 = [25 ,75, 25, 75, 25, 75, 25, 75, 25, 75] and s2 = [20, 75, 25, 75, 25, 75, 25, 75, 25, 75]

ie. 9 datapoints should be similar and 1 different?

Is my understanding correct here ?

• No that's not how correlation works. Mar 3, 2023 at 11:12
• I think you should check the formula for correlation. It will give you a better idea about how it is calculated. Mar 3, 2023 at 11:15
• Okay Thanks T.E.G
– Raj
Mar 3, 2023 at 11:17
• Can you please tell me what I am missing ? user2974951
– Raj
Mar 3, 2023 at 11:17
• I suggest you start from en.wikipedia.org/wiki/Correlation and go through the formula. Mar 3, 2023 at 11:22

That is not what correlation means. Correlation, either Pearson or Spearman, can be $$1$$ when all of the values are different. Further, either correlation can take values below zero, so this “proportion of equal values” interpretation cannot apply to such a situation.
$$\rho(X,Y)=\dfrac{ \overset{n}{\underset{i=1}{\sum}} \left[ (X_i-\bar X)(Y_i-\bar Y) \right] }{ \sqrt{ \overset{n}{\underset{i=1}{\sum}}\left[ (X_i-\bar X)^2 \right) }\sqrt{ \overset{n}{\underset{i=1}{\sum}}\left[ (Y_i-\bar Y)^2 \right) } }$$
Take $$X$$ and $$Y$$ to be the raw values for Pearson correlation or the ranks for Spearman correlation.
An example of perfect Pearson correlation with no equal values is $$X=(1,2,3)$$, $$Y=(11,21,31)$$, which also gives perfect Spearman correlation. An example of perfect Spearman correlation, imperfect Pearson correlation, and no equal values is $$X=(1,2,3)$$, $$Y=(11, 12, 15)$$.