Skip to main content
ponderloop

Correlation Coefficient Calculator

For the example data (advertising spend against monthly sales, 10 pairs) Pearson’s r ≈ 0.96356: a very strong positive correlation, with r² ≈ 0.92844, p ≈ 7.3835 × 10⁻⁶ and a 95% confidence interval for r of ≈ 0.84901 to 0.99160. Spearman’s rank correlation is ρ ≈ 0.96341. Paste your own x, y pairs (one pair per line, or x and y as two lists, up to 1,000 pairs) to get r, r², how strong it is, the p-value from an n − 2 degrees of freedom t test, a Fisher z confidence interval, Spearman’s ρ with a rank table, and a scatter plot with the line.

Updated Runs in your browser: nothing you enter is uploadedHow this tool works

One pair per line, x then y, separated by a comma, space or tab (a pasted spreadsheet range works). Up to 1,000 pairs. A first line of column names is skipped. Or put the x values here and the y values in the second box.

Up to 1,000 pairs.

Pearson correlation coefficient

r ≈ 0.96356

A very strong positive linear correlation (a rule of thumb): r² ≈ 0.92844 means about 92.844% of the variation in y goes with x along a straight line, from 10 pairs. p ≈ 7.3835 × 10⁻⁶, below 0.05, so r is statistically significant at the 5% level. The 95% confidence interval for r is ≈ 0.84901 to 0.99160. Spearman rank correlation: ρ ≈ 0.96341.

Pearson correlation

Pearson correlation coefficient (r)
≈ 0.96356
Coefficient of determination (r²)
≈ 0.92844
r² as a percentage
≈ 92.844%
Strength (rule of thumb)
Very strong, positive
t statistic
≈ 10.188
Degrees of freedom (n − 2)
8
p-value (two-tailed)
≈ 7.3835 × 10⁻⁶
95% confidence interval for r
≈ 0.84901 to 0.99160

Spearman rank correlation

Spearman rank correlation (ρ)
≈ 0.96341
Strength (rule of thumb)
Very strong, positive
t statistic
≈ 10.167
p-value (two-tailed)
≈ 7.4992 × 10⁻⁶
Tied values
x: 2 values in 1 tie group; y: 2 values in 1 tie group

The p-value uses the t distribution with n − 2 degrees of freedom, the usual approximation for ρ (SciPy’s spearmanr does the same); it is less reliable with fewer than about 10 pairs or many ties.

Working sums

Number of pairs (n)
10
Mean of x (x̄)
4.52
Mean of y (ȳ)
24.1
Sxx = Σ(x − x̄)²
25.096
Sxy = Σ(x − x̄)(y − ȳ)
95.68
Syy = Σ(y − ȳ)²
392.9
Σx
45.2
Σy
241
Σx²
229.4
Σy²
6,201
Σxy
1,185

Scatter plot

102030402468xy
10 pairs: x runs from 2.1 to 7.2 and y from 14 to 35. The line rises from left to right. Pearson r ≈ 0.9636.Each dot is one pair. The line is the least-squares line, drawn to show the direction of the trend; the closer the dots hug it, the closer |r| is to 1. The rank table below the plot lists the same pairs.

How strong is the correlation?

Rule-of-thumb bands for the size of |r| (the sign only gives the direction), and where your coefficients fall
|r| (or |ρ|)Labelr² (or ρ²)Your data
0.00 to below 0.20Very weak0 to below 0.04
0.20 to below 0.40Weak0.04 to below 0.16
0.40 to below 0.60Moderate0.16 to below 0.36
0.60 to below 0.80Strong0.36 to below 0.64
0.80 to 1.00Very strong0.64 to 1Pearson r and Spearman ρ

These labels are a rough convention, not a law: what counts as strong depends on the field, and a small n can make even a large r a fluke. The p-value and the confidence interval above say how much to trust it.

Rank table for Spearman’s ρ

Equal values share the average of the ranks they occupy, so a tie for ranks 2 and 3 gives both 2.5. Spearman’s ρ is Pearson’s r computed on these ranks.

Each pair with the rank of its x and of its y (1 is the smallest)
#xyRank of xRank of y
12.11411
22.81823
33.4173.52
43.4223.54
542455.5
64.72465.5
75.22777
85.93189
96.52998
107.2351010

How big does r have to be? Critical values for the p-value test

The smallest |r| that is statistically significant (two-tailed) for a given number of pairs, from the same t distribution the calculator uses: with 12 pairs, |r| must exceed 0.5760 at the 5% level.
Pairs (n)Degrees of freedom (n − 2)10% level5% level1% level
310.98770.99690.9999
420.90000.95000.9900
530.80540.87830.9587
640.72930.81140.9172
750.66940.75450.8745
860.62150.70670.8343
1080.54940.63190.7646
12100.49730.57600.7079
17150.41240.48210.6055
22200.35980.42270.5368
32300.29600.34940.4487
52500.23060.27320.3542
1021000.16380.19460.2540

What an r of a given size means

r, its square r² (the share of the variation in y that goes with x along a straight line) and the rule-of-thumb label for |r|.
r (or −r)r²r² as a percentageRule-of-thumb label
0.10.011%Very weak
0.30.099%Weak
0.50.2525%Moderate
0.70.4949%Strong
0.90.8181%Very strong
0.990.980198.01%Very strong

Pearson r against Spearman ρ on six patterns

The same pairs through both coefficients: they agree on steady trends and part ways on curves and outliers.
PatternData (x, y)Pearson rSpearman ρWhat it shows
A perfect straight line1, 2; 2, 4; 3, 6; 4, 811Both reach 1 when every point is on one rising line.
A steady rise with some scatter1, 2; 2, 4; 3, 5; 4, 4; 5, 6; 6, 7; 7, 8; 8, 9≈ 0.96529≈ 0.95810Close, because the trend is nearly straight.
The same data with one outlier1, 2; 2, 4; 3, 5; 4, 4; 5, 6; 6, 7; 7, 8; 8, 9; 9, 30≈ 0.73800≈ 0.97072One extreme point drags Pearson down; ranks barely notice it.
A curve that always rises, y = x³1, 1; 2, 8; 3, 27; 4, 64; 5, 125; 6, 216; 7, 343; 8, 512≈ 0.931831Spearman is exactly 1 for any steadily rising pattern; Pearson is lower because it is not a straight line.
A U-shaped curve, y = x² for x from −3 to 3-3, 9; -2, 4; -1, 1; 0, 0; 1, 1; 2, 4; 3, 900A strong relationship with zero correlation: neither coefficient sees a U.
A heating bill that falls as it warms30, 210; 35, 190; 42, 165; 50, 130; 55, 110; 63, 80; 70, 60≈ −0.99879−1A perfect rank order (ρ is −1) on a nearly straight line.

Worked examples

Eight short problems, each answered by the calculator on the data shown (x, y pairs separated by semicolons), at the 95% level.
ProblemDataPearson rSpearman ρp-value for r95% confidence interval for r
Advertising spend and monthly sales, in $1,000s (the example above)2.1, 14; 2.8, 18; 3.4, 17; 3.4, 22; 4.0, 24; 4.7, 24; 5.2, 27; 5.9, 31; 6.5, 29; 7.2, 35≈ 0.96356≈ 0.96341≈ 7.3835 × 10⁻⁶≈ 0.84901 to 0.99160
Outdoor temperature (°F) and a monthly heating bill ($): as one rises the other falls30, 210; 35, 190; 42, 165; 50, 130; 55, 110; 63, 80; 70, 60≈ −0.99879−1≈ 9.7232 × 10⁻⁸≈ −0.99983 to −0.99146
A noisy relationship in a small sample1, 5; 2, 3; 3, 6; 4, 4; 5, 7; 6, 3; 7, 8; 8, 5≈ 0.30649≈ 0.27713≈ 0.46030≈ −0.50787 to 0.83157
A steady rise, 8 pairs1, 2; 2, 4; 3, 5; 4, 4; 5, 6; 6, 7; 7, 8; 8, 9≈ 0.96529≈ 0.95810≈ 0.00010180≈ 0.81499 to 0.99390
The same data with one outlier added at (9, 30)1, 2; 2, 4; 3, 5; 4, 4; 5, 6; 6, 7; 7, 8; 8, 9; 9, 30≈ 0.73800≈ 0.97072≈ 0.023199≈ 0.14489 to 0.94094
A curve that always rises, y = x³ for x from 1 to 81, 1; 2, 8; 3, 27; 4, 64; 5, 125; 6, 216; 7, 343; 8, 512≈ 0.931831≈ 0.00075199≈ 0.66157 to 0.98785
Scores with tied values (average ranks)1, 3; 2, 2; 2, 4; 3, 3; 4, 6; 4, 5; 5, 7; 6, 7≈ 0.88745≈ 0.87805≈ 0.0032705≈ 0.48786 to 0.97955
Every x is the same4, 1; 4, 2; 4, 3Undefined (all x values are equal)Undefined (all x values or all y values are equal)Undefined (all x values are equal)Undefined (all x values are equal)

How to calculate a correlation coefficient by hand

  1. Find the means. Add up the x values and the y values and divide each sum by the number of pairs. For the example, Σx = 45.2 and Σy = 241, so x̄ = 4.52 and ȳ = 24.1 with n = 10.
  2. Add up the spreads. Sxx = Σx² − (Σx)² ÷ n, Syy = Σy² − (Σy)² ÷ n and Sxy = Σxy − Σx × Σy ÷ n. For the example Sxx = 25.096, Syy = 392.9 and Sxy = 95.68.
  3. Divide for r. r = Sxy ÷ √(Sxx × Syy) = 95.68 ÷ √(25.096 × 392.9) ≈ 0.96356. Square it for r² ≈ 0.92844.
  4. Test it against zero. Find t = r × √((n − 2) ÷ (1 − r²)) ≈ 10.188 with 8 degrees of freedom, then look up the two-tailed p-value: p ≈ 7.3835 × 10⁻⁶. A p-value below 0.05 means r is statistically significant at the 5% level.
  5. Add a confidence interval. Fisher’s z = atanh(r) ≈ 1.9934 has standard error 1 ÷ √(n − 3) ≈ 0.37796. For 95%, take z ± 1.9600 × 0.37796, then convert back with tanh to get ≈ 0.84901 to 0.99160.

Frequently asked questions

What is a correlation coefficient?
A single number between −1 and 1 that says how closely two variables move together. Pearson’s r measures the straight-line part of that: +1 is a perfect rising line, −1 a perfect falling line and 0 no straight-line relationship. For the example (advertising spend and sales) r ≈ 0.96356, so the points lie very close to a rising line. Spearman’s ρ does the same on ranks.
How do you calculate Pearson’s r?
r = Sxy ÷ √(Sxx × Syy), where Sxx and Syy are the sums of squared deviations of x and y from their means and Sxy is the sum of the products of the deviations. For the example Sxy = 95.68, Sxx = 25.096 and Syy = 392.9, giving r ≈ 0.96356. The calculator forms these sums as exact fractions, so only the final square root is approximate. The same number is what a spreadsheet’s CORREL function returns.
How do I interpret r?
Read the sign for the direction (positive: y tends to rise with x; negative: it falls) and the size of |r| for the strength. A common rule of thumb calls |r| from 0.00 to 0.20 very weak, 0.20 to 0.40 weak, 0.40 to 0.60 moderate, 0.60 to 0.80 strong and 0.80 to 1.00 very strong. The example is very strong, positive. The labels are a convention, not a law, and different fields use different cut-offs. r² tells you more: r² ≈ 0.92844 means that about 92.844% of the variation in sales goes with spend along a straight line.
What is the difference between Pearson and Spearman correlation?
Pearson’s r measures how well the pairs follow a straight line, using the values themselves, so outliers and curves affect it. Spearman’s ρ replaces each value by its rank and then computes Pearson’s r on the ranks, so it measures how consistently y rises (or falls) with x, whatever the shape. For y = x³ on x from 1 to 8 Spearman gives ρ = 1 while Pearson gives r ≈ 0.93183. Adding one outlier to a steady rise moves Pearson from 0.96529 to 0.73800, while Spearman goes from 0.95810 to 0.97072.
How does Spearman’s correlation handle tied values?
Tied values get the average of the ranks they would have occupied: two values tied for ranks 2 and 3 both get rank 2.5. The rank table shows this for the first 50 pairs. In the example the repeated x value 3.4 and the repeated y value 24 each take an average rank, and ρ ≈ 0.96341. Because ρ is computed as Pearson’s r of these ranks, it stays correct with ties; the tie counts are listed under the Spearman results (x: 2 values in 1 tie group; y: 2 values in 1 tie group).
How is the p-value for r calculated?
The test asks whether a correlation this large could easily arise from unrelated variables. It uses t = r × √((n − 2) ÷ (1 − r²)) with n − 2 degrees of freedom and reads the two-tailed probability from Student’s t distribution. For the example t ≈ 10.188 on 8 degrees of freedom gives p ≈ 7.3835 × 10⁻⁶. The p-value is not the probability that r is zero; it is how surprising a result at least this extreme would be if the true correlation were zero. The test assumes the pairs are independent and roughly bivariate normal.
How is the confidence interval for r calculated?
r’s sampling distribution is skewed, so the interval is built on Fisher’s z = atanh(r), which is close to normal with standard error 1 ÷ √(n − 3). The calculator takes z ± (the normal critical value) × that standard error and converts the ends back with tanh. For the example the 95% interval is ≈ 0.84901 to 0.99160; it is not symmetric around r, and it is the same method SciPy uses. It needs at least 4 pairs and is not defined when |r| is 1. The “Confidence level” menu offers 90%, 95% and 99%.
How large must r be to be statistically significant?
It depends on the number of pairs: more pairs, smaller r needed. With 12 pairs (10 degrees of freedom) |r| must exceed 0.5760 at the 5% level; the critical-value table above lists other sizes at the 10%, 5% and 1% levels. Significance is not importance: with a very large sample a tiny r is significant, and with a small sample even a large r may not be. For r = 0.5 the 95% interval is −0.189 to 0.859 with 10 pairs but only 0.337 to 0.634 with 100.
Does a high correlation mean one thing causes the other?
No. Two variables can move together because one causes the other, because a third factor drives both, or by coincidence. Correlation describes the data you have; it cannot tell you which way, if any, causation runs. It also says nothing about how much y would change if you changed x, which is a question for a fitted line or an experiment.
Can r be 0 when there is a clear relationship?
Yes. Pearson’s r only detects straight-line trends. For the U-shaped data y = x² on x from −3 to 3 (-3, 9; -2, 4; -1, 1; 0, 0; 1, 1; 2, 4; 3, 9) the calculator gives r = 0 and ρ = 0, although y is exactly determined by x. Always look at the scatter plot as well as the number.
What happens with only two pairs, or when all values are equal?
With two pairs the line through them is perfect, so r is always 1 or −1 (1, 3; 2, 8 gives r = 1) and there is no test: the p-value needs at least 3 pairs (the calculator says “Needs at least 3 pairs”) and the interval at least 4. If every x (or every y) is the same, r is undefined because it divides by the spread: for 4, 1; 4, 2; 4, 3 the calculator shows “Undefined (all x values are equal)” instead of a made-up number.
How do I enter the data, and what are the limits?
Put one pair per line, with x and y separated by a comma, a space, a tab or a semicolon, so a copied spreadsheet range works. A first line of column names is skipped. Or put the x values in the first box and the y values in the second. Up to 1,000 pairs are used; more are refused rather than cut, so the result always covers everything you pasted. A line that is not two numbers is reported with its line number.
Is the result exact?
For ordinary decimals (up to 30 digits each) the sums, means, Sxx, Sxy, Syy and r² are exact fractions, and only the square root for r is approximate, found to 30 decimals; Spearman’s ranks are exact too. If you type a value in exponent notation (1.5e3) or with more than 30 digits, the whole data set is computed in double precision and every figure carries ≈. The p-value and the interval use floating-point numerics, checked against SciPy to many digits. The “Significant digits” menu rounds what you see, half away from zero.
How is this different from the linear regression calculator?
This page is about how strong the relationship is: r, r², its significance and confidence interval, and rank correlation. A regression calculator is about the line itself: the slope, the intercept, predictions and residuals. The scatter plot here draws the least-squares line only so you can see the trend that r summarises.

How it works

Each x and y is read as an exact decimal (up to 30 digits) and the sums use exact fractions of whole numbers. With n pairs: Sxx = Σx² − (Σx)² ÷ n, Syy = Σy² − (Σy)² ÷ n and Sxy = Σxy − Σx × Σy ÷ n, which avoids the cancellation error of the textbook shortcut in floating point. Pearson’s r = Sxy ÷ √(Sxx × Syy) and r² = Sxy² ÷ (Sxx × Syy) is exact; the square root is found with integer arithmetic to 30 decimals and is exact for perfect squares. If a value uses exponent notation or has more than 30 digits, the sums are taken in double precision (means first, then squared deviations) and results are marked ≈. Spearman’s ρ is Pearson’s r of the ranks, where tied values receive the mean of the ranks they span; ranks are multiples of one half, so ρ is exact. The significance test is t = r √((n − 2) ÷ (1 − r²)) with n − 2 degrees of freedom and a two-tailed p-value from Student’s t distribution (the same test SciPy’s pearsonr uses, and the usual approximation for spearmanr). The confidence interval is tanh(atanh(r) ± z* ÷ √(n − 3)) with z* the standard normal critical value for the chosen level; it needs n ≥ 4. The critical values of r in the table are t* ÷ √(df + t*²). The strength labels (very weak below 0.20, weak, moderate, strong, very strong from 0.80) are a rule of thumb after Evans (1996), not a statistical standard. The scatter plot converts the numbers to floating point only to place them on the page and draws the least-squares line for orientation. The rank table lists the first 50 pairs in the order entered. Numerics for the t and normal distributions are in double precision and were checked against SciPy. This describes the data you enter; it does not show causation.

Sources

More: Statistics, probability and gradesAll math & numbersAll toolsHome & DIY calculators