01
How to calculate a correlation coefficient
- Paste the X values in the first box and the Y values in the second, in the same order: the first X belongs with the first Y.
- Read r. It updates as you type.
- Look at the scatter plot before you interpret the number: one outlier or a curved pattern can make r misleading.
02
Pearson correlation formula
r = Σ(x − x̄)(y − ȳ) ÷ √( Σ(x − x̄)² × Σ(y − ȳ)² )
r runs from −1 (a perfect falling line) through 0 (no linear relationship) to +1 (a perfect rising line). Its square, r², is the share of the variation in one variable that a straight-line relationship with the other accounts for.
03
Worked example
The calculator opens with X = 1, 2, 3, 4, 5 and Y = 2, 4, 5, 4, 5. The means are 3 and 4.
Σ(x − x̄)(y − ȳ) = 6, Σ(x − x̄)² = 10, Σ(y − ȳ)² = 6
r = 6 ÷ √(10 × 6) = 0.775, r² = 0.60
With only five pairs this is not statistically significant (p = .124), and the 95% confidence interval runs from −.34 to .98: a strong correlation in the sample, but little certainty about the population. The best-fit line is y = 2.2 + 0.6x.
04
How to interpret r
| |r| | Label (Cohen, 1988) |
|---|---|
| below 0.10 | negligible |
| 0.10 to 0.29 | small |
| 0.30 to 0.49 | medium |
| 0.50 and above | large |
These labels are a rough guide; what counts as strong depends on the field. And a correlation, however strong, does not show that one variable causes the other.
05
p value and confidence interval
t = r × √(n − 2) ÷ √(1 − r²), on n − 2 degrees of freedom
95% CI: tanh( atanh(r) ± 1.96 ÷ √(n − 3) )
The p value tests whether the population correlation is zero. The interval, from Fisher’s z transformation, shows the range of population correlations compatible with your data, and is usually the more informative of the two.
06
Spearman’s rank correlation
Choose “Spearman (ranks)” when the data are ordinal, contain outliers, or rise together along a curve instead of a line. Each variable is replaced by its ranks (tied values share the average rank) and Pearson’s formula is applied to the ranks.
For the opening example the Y ranks are 1, 2.5, 4.5, 2.5 and 4.5, and Spearman’s rho is 0.738, against a Pearson r of 0.775. The two differ most when one extreme point dominates the data.
07
When Pearson’s r is the wrong tool
- Curved relationships. r only measures straight-line association; a perfect U-shape can give r = 0.
- Outliers. A single extreme pair can create or hide a correlation.
- Ranks or ordinal scales. Switch the calculator to Spearman.
- Two groups rather than two measurements. Compare means with the t-test calculator.
08
Common mistakes with correlation
- Letting one outlier decide. X = 1 to 5 with Y = 3, 1, 4, 2, 3 gives r = 0.14; add a single pair at (20, 20) and r jumps to 0.97, p = .001.
- Reading a curve as “no relationship”. Y = X² for X from −3 to 3 is a perfect relationship, yet r = 0.
- Judging r without n. r = 0.775 is not significant with 5 pairs (p = .124) but gives p < .001 with 20 pairs.
Trust
How this page is checked
- The calculation runs on code with automated tests against worked reference values. Every number in the examples on this page was produced by that same code, not typed by hand.
- The formulas and conventions used are stated on the page, so you can reproduce the result yourself or compare it with your own software.
- Last reviewed by the Sciloom team, Zebra Nine Studio Inc. It is a tool for research and teaching, not a substitute for a statistician, a validated lab method or medical advice.
Cite this page
Sciloom. (2026). Correlation coefficient calculator. Zebra Nine Studio Inc. https://sciloom.si/correlation-coefficient-calculator
Frequently asked questions
What is a good correlation coefficient?
It depends on the field. As a rough guide, an absolute r of 0.1 is small, 0.3 medium and 0.5 or more large. In physical measurement much higher values are expected.
What is the difference between r and r²?
r gives the direction and strength of a linear relationship. r² is the proportion of variance in one variable accounted for by the other: r = 0.5 means r² = 0.25, or 25%.
Is my correlation statistically significant?
The calculator tests r against zero with a t-test on n − 2 degrees of freedom and reports the two-tailed p value. With few pairs, even a large r may not be significant.
Does correlation mean causation?
No. Two variables can move together because one causes the other, because a third factor drives both, or by chance.