What this calculator does
Find out how closely two sets of numbers move together, such as ad spending and sales. The Pearson correlation coefficient, r, is one number that measures how well the two follow a straight line. It runs from −1 (a perfect downward line) through 0 (no straight-line pattern) to +1 (a perfect upward line). It has no units. So you can compare relationships measured on completely different scales.
Enter paired x and y values. The calculator gives you r, r² and the sample covariance (how much the two vary together, in their own units). It also runs a significance test, which asks whether a pattern this strong could be luck. You get the t statistic and the two-sided p-value. Both test the starting assumption (the null hypothesis) that the true correlation is zero.
Where it's used
Why this math matters outside the classroom:
- Study time. A teacher finds r = 0.8 between hours studied and test scores, a strong positive linear association.
- Ice cream sales. An ice cream shop finds that daily sales and afternoon temperature have r = 0.9, a strong positive link.
- Correlation vs cause. Ice cream sales and swimming accidents both rise in summer, so a high r alone does not show that one causes the other.
- Diversifying. Investors check the correlation between two funds' returns, since an r near 0 means they tend not to move together.
- Body measurements. Students who measure classmates' heights and arm spans find r close to 1, since the two lengths track each other closely.
Grade level and standards: Grades 9–10; Common Core State Standards for Mathematics HSS.ID.C.8, HSS.ID.C.9. © Copyright 2010. National Governors Association Center for Best Practices and Council of Chief State School Officers. All rights reserved.
How to use it
- Enter the x values in the first box, separated by commas, spaces or new lines.
- Enter the y values in the second box in the same order, so each y lines up with its x. You need at least three pairs.
- Read r as the main result. Below it you'll find r², the t statistic, the degrees of freedom and the p-value.
What the inputs mean
- X values
- Unlike regression, it doesn't matter which set you call x and which y. r is the same either way.
- Y values
- Must have exactly as many values as the x list. Neither list can have all the same value. A number that never changes can't move with anything.
Formula and method
r = Σ(x − x̄)(y − ȳ) / √(Σ(x − x̄)² × Σ(y − ȳ)²) = Sxy / √(Sxx × Syy) t = r × √((n − 2) / (1 − r²)), with n − 2 degrees of freedom p = 2 × P(T > |t|) sample covariance = Sxy / (n − 1)
In the formulas, x̄ and ȳ are the averages (means) of the x and y values, and n is the number of pairs. Σ means "add up over every pair". x − x̄ is how far each x sits from its average, called its deviation. Sxx and Syy add up the squared deviations of x and of y. Sxy adds up each pair's two deviations multiplied together.
When large x values go with large y values, most of those products are positive, so Sxy is positive. Dividing by √(Sxx × Syy) rescales it, so the result always lands between −1 and 1.
Could your r have come about by chance from two unrelated sets of numbers? To test that, r is turned into a t statistic. The p-value is the chance of a t statistic at least this far from zero, in either direction, if the true correlation were zero. P(T > |t|) is that chance on one side, so it's doubled.
Worked example
Eight weeks of advertising spend (2, 4, 5, 7, 8, 10, 11 and 13 hundred dollars) and sales (15, 21, 20, 27, 26, 33, 31 and 38 units). How strongly are they related?
- Sxx = 98, Syy = 399.875 and Sxy = 193.5.
- r = 193.5 ÷ √(98 × 399.875) ≈ 0.977475.
- r² ≈ 0.955458, so about 95.5% of the variation is shared.
- t = 0.977475 × √(6 ÷ (1 − 0.955458)) ≈ 11.3448 with 6 degrees of freedom.
- Two-sided p ≈ 0.0000281.
Result: r ≈ 0.9775, a very strong positive straight-line relationship. p ≈ 0.000028, so a correlation this strong would be very unlikely if spend and sales were unrelated.
Understanding the result
The sign gives the direction, and the size gives the strength. Values near ±1 mean the points hug a line. Values near 0 mean there's no straight-line pattern, though there may still be a curved one.
r² is the share of the ups and downs that the two variables have in common. An r of 0.5 sounds moderate. But r² = 0.25 means only a quarter of the variation is shared.
A small p-value says the correlation is unlikely to be exactly zero. It doesn't say the correlation is large or important. With thousands of pairs, even r = 0.05 can be statistically significant. A p-value is also not the chance that there's no correlation. It's the chance of data at least this extreme if there were none.
Assumptions and limitations
- Pairs are independent of one another, such as different people or units, not repeated readings over time.
- The relationship is a straight line. Pearson's r can miss or understate a strong curved relationship.
- For the p-value, the two variables are assumed to be roughly bivariate normal (each follows a bell curve, and so do they jointly). With medium or large samples, the test still works fairly well when the data are a little off.
- Correlation is not causation. A third factor may drive both, or the influence may run the other way.
- A single outlier (one point far from the rest) can inflate or hide a correlation. So plot the data before relying on r.
- Rank-based measures such as Spearman's rho, and confidence intervals for r, are not calculated here.
- The test is two-sided only and assumes the null value is zero.
Frequently asked questions
What counts as a strong correlation?
It depends on the field. In physics a correlation of 0.9 may be disappointing, while in social science 0.3 can be worth noting. Rough everyday labels call |r| below 0.3 weak, 0.3 to 0.7 moderate and above 0.7 strong. Still, context matters more than any cutoff.
Why do I need at least three pairs?
Two points always lie exactly on a line, so r would be ±1 automatically. The test would also have zero degrees of freedom. Three pairs is the minimum for a meaningful test, and in practice you need far more for a precise estimate.
What does the p-value tell me?
It's the chance of seeing a correlation at least as strong as yours, in either direction, if the true correlation were zero. It's not the chance that the correlation is real, or that the null hypothesis is true.
How is this related to linear regression?
In simple linear regression (fitting one straight line), R² is exactly r², and the slope has the same sign as r. Testing whether the slope is zero gives the same p-value as this correlation test.
How this calculator is checked
Method: Pearson product-moment correlation from centered sums of squares, with the standard t test t = r√((n − 2)/(1 − r²)) on n − 2 degrees of freedom. The two-sided p-value is computed from the regularized incomplete beta function. The calculation is covered by automated tests with known reference values and edge cases. Last updated 2026-10-18. Found a problem? Tell us.
Embed this calculator
Put this Correlation Coefficient Calculator on your own website or blog for free. Paste this code where you want it to appear: