Correlation coefficient calculator
Enter two lists of the same length, X and Y. You get Pearson's r, r squared, the t statistic and degrees of freedom, the two-sided p-value for the hypothesis of no linear correlation, and the sample covariance.
Runs in your browser: nothing you enter is sent anywhere.
How to use it
- Enter your X values and your Y values in the same order.
- Read r and r². A negative r means Y falls as X rises.
- Check the p-value to judge whether the correlation could be chance.
How it works
The calculator subtracts each mean first, which keeps the arithmetic stable, then divides the sum of cross-products by the square root of the product of the sums of squares. The t statistic uses n − 2 degrees of freedom and the p-value comes from the Student t distribution. Perfect correlation (r = ±1) gives p = 0.
Worked example
X = 1, 2, 3, 4, 5 and Y = 2, 4, 5, 4, 5:
- Means 3 and 4; Σ(x − x̄)(y − ȳ) = 6, Σ(x − x̄)² = 10, Σ(y − ȳ)² = 6
- r = 6 / √60 ≈ 0.7746, r² = 0.6
- t = r × √(3 / 0.4) ≈ 2.121 with 3 degrees of freedom, p ≈ 0.124
Tips
- One outlier can change r a lot, so plot your data as well.
- With few pairs a large r can still be insignificant, as in the example.
Frequently asked questions
What does the Pearson correlation coefficient measure?
The strength and direction of a straight-line relationship between two variables. It ranges from −1 (perfect negative) through 0 (none) to +1 (perfect positive).
What is the formula for r?
r = Σ(x − x̄)(y − ȳ) / √(Σ(x − x̄)² × Σ(y − ȳ)²). For X = 1…5 and Y = 2, 4, 5, 4, 5 that is 6 / √60 ≈ 0.775.
What does the p-value mean here?
It is the probability of seeing a correlation at least this far from 0 if the true correlation were 0, using t = r√((n − 2)/(1 − r²)) with n − 2 degrees of freedom. It assumes roughly normal data.
What is r squared?
The share of the variance in Y that a straight line on X accounts for. With r = 0.775, r² = 0.6, so 60%.
Does a high correlation mean one thing causes the other?
No. Two variables can move together because of a third factor or by chance, especially in small samples.