Maximum decimal places: 6; Nearest, ties away from zero
Strength
Strong positive
Coefficient of determination r²
0.963613
t statistic
14.555426
Degrees of freedom
8
p-value (two-sided)
4.865 × 10⁻⁷
Pairs n
10
r = 0.9816. Strength: Strong positive; association: linear. r² = 0.9636: a least-squares line with an intercept accounts for 96.36% of the observed variation in y. The Pearson t-test gives p = 4.86 × 10⁻⁷ for 10 independent pairs under its null-model assumptions. Correlation alone does not establish causation.
y against x
PairsLeast-squares line
How it's calculated S
Means
xˉ=4.3,yˉ=66.8
Sums of squares and cross-products
Sxx=48.1,Syy=993.6,Sxy=214.6
Correlation
r=SxxSyySxy=48.1×993.6214.6=0.981638
Test statistic
t=r1−r2n−2=0.9816381−0.9636138=14.555426
Two-sided p-value
p=2P(T8>∣t∣)=4.86464×10−7
Assumes the pairs are independent and roughly bivariate normal.
About the correlation coefficient calculator
Pearson's r measures how closely paired values follow a straight line: r = Sxy/√(Sxx·Syy), the sum of cross-products of deviations from the two means divided by the square root of the product of the two sums of squares. It runs from −1, a perfect falling line, through 0 to +1, a perfect rising line. Spearman's ρ is Pearson's r computed on the ranks, so it measures any steadily rising or falling trend and is less affected by outliers. The p-value comes from t = r√((n − 2)/(1 − r²)) with n − 2 degrees of freedom. For Pearson, this reference test assumes independent pairs from a bivariate normal population under zero correlation. For Spearman it is an approximation, not an exact permutation test.
The default pairs hours studied with exam scores for 10 students: r = 0.9816, r² = 0.9636 and p = 4.9 × 10⁻⁷, a strong positive association.
A correlation near 0 rules out only a straight-line relationship: y = x² for x from −3 to 3 has r = 0 exactly.
How to calculate the Pearson correlation coefficient
Pearson's correlation is r = Sxy ÷ √(Sxx × Syy), where Sxy sums the cross-products of deviations from the two means and Sxx and Syy sum the squared deviations. For 10 students' hours studied and exam scores, r = 0.9816, a strong positive linear association.
The data pair hours 1, 2, 2, 3, 4, 5, 5, 6, 7 and 8 with scores 52, 55, 61, 58, 66, 70, 68, 75, 79 and 84. Worked by hand:
r runs from −1, a perfect falling line, through 0 to +1, a perfect rising line. The sign gives the direction and the size gives how tightly the points hug a straight line.
What r and r² mean
For a straight line fitted by least squares, r² is the share of the variation in y the line accounts for. Here r² = 0.9636, so the line explains 96.4% of the spread in scores. An r of 0.7 gives r² = 0.49, or 49%.
Cohen (1988) called r = 0.1 small, 0.3 medium and 0.5 large, and the strength labels follow those cut-offs. They are rough conventions from the behavioral sciences, so what counts as strong still depends on the field.
Is the correlation significant?
Convert r to t = r × √((n − 2) ÷ (1 − r²)) and compare it with a t distribution on n − 2 degrees of freedom. The example gives t = 14.56 on 8 df and a two-sided p-value of 4.9 × 10⁻⁷.
Significance depends heavily on n. With 1,000 pairs, r = 0.07 already gives p = 0.027, although it explains under 0.5% of the variation.
The Pearson test assumes independent pairs drawn from a bivariate normal population when the true correlation is zero (SciPy).
Pearson vs Spearman correlation
Spearman's ρ applies Pearson's formula to the ranks of each variable, so it measures any steadily rising or falling trend, straight or curved. For y = x³ with x from 1 to 10, Spearman gives exactly 1, while Pearson gives 0.928.
Ties get the average of the ranks they span. The x values 1, 2, 2, 3, 4, 5, 5, 6 rank as 1, 2.5, 2.5, 4, 5, 6.5, 6.5, 8. Paired with y = 3, 1, 4, 4, 5, 9, 2, 6, they give ρ = 0.5758.
That example's p-value of 0.1353 comes from the same t formula, which is an approximation for Spearman. For 500 or fewer pairs, a permutation test is the more exact choice (SciPy).
Spearman also suits ordinal data such as ratings and resists outliers. Pearson's r is the one that matches a least-squares line.
One outlier can change everything
Pearson's r uses the values themselves, so one bad point can swamp the rest. If the last score in the example were entered as 30 instead of 84, r would fall from 0.982 to 0.051 and look negligible.
Spearman on the same data gives 0.427, still a moderate positive trend. Plot the data before trusting either number: a scatterplot shows outliers, curves and clusters that one coefficient hides.
Why r = 0 does not mean no relationship
r measures straight-line association only. For x = −3, −2, −1, 0, 1, 2, 3 and y = x², r is exactly 0, yet each y is fixed by its x. The curve rises on both sides, and the two halves cancel.
Correlation is not causation
A correlation shows that two variables move together, not why. A third variable can drive both, as hot weather raises both ice-cream sales and drownings.
The cause can also run the other way, or the pattern can be chance: test 20 unrelated pairs at α = 0.05 and about one will look significant.
Correlation examples
Scenario
Coefficient
Two-sided p-value
Default
0.981638
4.864640E-7
Negative
-0.891042
0.017161
Spearman ties
0.575768
0.135297
Zero correlation
0.000000
1.000000
Cubic Spearman
1.000000
0.000000
"Default" is the hours example and "Spearman ties" the tied-ranks example. "Negative" pairs x = 10, 20, 30, 40, 50, 60 with y = 8.1, 7.4, 7.9, 6.2, 5.8, 6. "Zero correlation" is the y = x² example, and "Cubic Spearman" pairs x = 1 to 5 with their cubes.
At ρ = ±1 the t statistic is infinite, so the p-value is reported as 0. For Spearman that 0 comes from the approximation; an exact permutation p-value is never 0, because the observed ordering always counts.
Entering paired data
Keep the pairs in order. Each x must sit in the same position as its y; sorting one list alone pairs different observations.
At least three pairs are needed for the t-based p-value.
A constant list has no correlation. If every x or every y is equal, r is undefined, not 0.
Separate values with spaces or a comma and a space. A token like 101,102,103 could be read as one number with thousands separators.
Checked against: For Sxx, Syy, Sxy with a decimal square root; p from the closed-form Student t CDF for integer df (Abramowitz & Stegun 26.7.4)
Negative association
x values
10, 20, 30, 40, 50, 60
y values
8.1, 7.4, 7.9, 6.2, 5.8, 6.0
Coefficient
Pearson r
Correlation coefficient
-0.891042
t statistic
-3.925982
p-value (two-sided)
0.017161
Strength
Strong negative
Checked against: With decimal square roots; p = 2·(1 − F_t(|t|; 4)) from the A&S 26.7.4 closed form
Spearman with tied ranks
x values
1, 2, 2, 3, 4, 5, 5, 6
y values
3, 1, 4, 4, 5, 9, 2, 6
Coefficient
Spearman ρ
Correlation coefficient
0.575768
t statistic
1.724946
p-value (two-sided)
0.135297
Degrees of freedom
6
Strength
Strong positive
Checked against: Ties averaged by hand (x ranks 1, 2.5, 2.5, 4, 5, 6.5, 6.5, 8), Pearson r of the ranks with fractions (Sxy = 95/4, Sxx = 41, Syy = 83/2), p from the A&S 26.7.4 t CDF
Perfect straight line
x values
1, 2, 3, 4
y values
3, 5, 7, 9
Coefficient
Pearson r
Correlation coefficient
1
Coefficient of determination r²
1
p-value (two-sided)
0
Strength
Strong positive
Checked against: y = 2x + 1 exactly, so r = 1 by definition and no sample could be more extreme
Questions
What does a correlation coefficient of 0.7 mean?
A fairly strong positive linear association: as x rises, y tends to rise, and r² = 0.49 says a straight line accounts for 49% of the variation in y. Cohen (1988) called r = 0.1 small, 0.3 medium and 0.5 large, and the Strength output uses those cut-offs. They are rough conventions from the behavioural sciences, so what counts as strong still depends on the field.
What is the difference between Pearson and Spearman correlation?
Pearson's r measures linear association using the values themselves; Spearman's ρ applies the same formula to their ranks, so it measures any monotonic trend. For y = x³ with x from 1 to 10, Spearman gives exactly 1 but Pearson gives 0.928. Spearman also resists outliers and suits ordinal data such as ratings, while Pearson's r is the one that matches a least-squares line.
Does correlation imply causation?
No. A correlation shows that two variables move together, not why. A third variable can drive both, as hot weather raises both ice-cream sales and drownings. The cause can also run the other way, or the pattern can be chance: test 20 unrelated pairs at α = 0.05 and about one will look significant. Showing cause takes a randomized experiment or a careful causal design.
How do you test whether a correlation is significant?
Convert r to t = r√((n − 2)/(1 − r²)) and compare it with a t distribution with n − 2 degrees of freedom. The default data give r = 0.9816 with n = 10, so t = 14.56 on 8 df and p = 4.9 × 10⁻⁷. Significance depends heavily on n: with 1,000 pairs, r = 0.07 already gives p = 0.027, although it explains under 0.5% of the variation.
Spearman (1904), The proof and measurement of association between two things, American Journal of Psychology 15
Cohen (1988), Statistical Power Analysis for the Behavioral Sciences, 2nd ed., §3.2 (r = 0.1, 0.3, 0.5)
Checked against references
This calculator includes 4 worked examples with independently sourced answers. They run in the test suite, and you can run them here too.
Put this calculator on your site
Paste this where you want the calculator to appear. It is free to use, it stays in step with corrections made here, and the credit line below it links back so your readers can find the full version.