A correlation coefficient condenses a scatter plot into one number between −1 and +1: its sign gives the direction and its size the strength of the association. This calculator computes both of the coefficients you are likely to need, Pearson’s r for straight-line relationships and Spearman’s ρ for rank-based, monotonic ones, along with r², a significance test, a confidence interval for r and a scatter plot of your data.
How to use the correlation calculator
- Paste the X values in the first box and the matching Y values, in the same order, in the second.
- Choose which coefficient to show as the headline; both are always reported.
- Read r, r² and the p-value on the tape, check the scatter plot for curves or outliers, and use the working table to follow the arithmetic.
Correlation formulas
Pearson’s r divides the cross-product of deviations by the product of their spreads:
Spearman’s ρ is Pearson’s r applied to the ranks of the data. With no tied values it simplifies to
where d is the difference between each pair’s ranks. Tied values get the average of the ranks they span. To test whether a coefficient differs from zero, the calculator uses
and the 95% interval for r comes from Fisher’s transformation z = artanh(r), whose standard error is 1 ÷ √(n − 3).
Worked example
Ten students report hours studied and their exam scores:
| Hours (x) | 2 | 3 | 5 | 1 | 4 | 6 | 7 | 3 | 8 | 5 |
|---|---|---|---|---|---|---|---|---|---|---|
| Score (y) | 68 | 64 | 75 | 62 | 80 | 79 | 90 | 72 | 86 | 70 |
- Means: x̄ = 4.4 hours and ȳ = 74.6 points.
- Sums: Sxx = 44.4, Syy = 758.4 and Sxy = 160.6.
- r = 160.6 ÷ √(44.4 × 758.4) = 0.8752, a very strong positive relationship.
- r² = 0.766: about 77% of the variation in scores lines up with study time.
- t = 0.8752 × √(8 ÷ (1 − 0.766)) = 5.117 with 8 df, so p = 0.0009.
- The 95% confidence interval for the population correlation is 0.547 to 0.970, wide because there are only ten students.
- Spearman’s ρ = 0.854, close to r, which suggests the relationship is roughly linear without outliers driving it.
Interpreting correlation
Size versus significance
The p-value answers “could r be zero?”, not “is r large?” With 1,000 pairs, r = 0.07 is statistically significant yet explains under 1% of the variation. With 6 pairs, r = 0.75 may not reach significance. Report r with its confidence interval so readers see both strength and uncertainty.
Outliers and restricted ranges
A single extreme point can create or destroy a Pearson correlation; Spearman is far less sensitive. Restricting the range also weakens correlations: SAT scores correlate less with college grades among admitted students than among all applicants, because the low scorers are missing.
Pearson and Spearman disagreeing
When ρ is much larger than r, the relationship is probably monotonic but curved. When r is much larger than ρ, look for a few points far from the rest. The calculator flags a gap larger than 0.2.
For the equation of the best-fit line, use the linear regression calculator. For the unstandardized measure of joint variability that r is built on, see the covariance calculator.
Frequently asked questions
What is a good correlation coefficient?
It depends on the field. In physics or engineering, anything below 0.95 may signal a problem; in psychology or economics, 0.3 can be meaningful. A rough general scale is 0.2 weak, 0.4 moderate, 0.6 strong and 0.8 very strong, applied to the absolute value.
When should I use Spearman instead of Pearson?
Use Spearman when the data are ranks or ordinal scores, when the relationship is monotonic but curved, or when outliers would dominate Pearson's r. Spearman works on ranks, so it only asks whether y tends to rise as x rises, not whether the rise is a straight line.
What does r² mean?
r² is the share of the variation in y that a straight-line fit on x accounts for. With r = 0.875, r² = 0.766, so about 77% of the spread in y lines up with x and 23% does not. It is the same R² that a simple linear regression reports.
Does a significant correlation prove causation?
No. A third variable may drive both, the direction may run the other way, or the link may be coincidence. Ice cream sales and drowning deaths correlate because both rise in hot weather. Causal claims need a controlled experiment or careful causal analysis.
Can the correlation be zero when the variables are related?
Yes. Pearson's r measures only straight-line association. Points that form a U shape or a circle can have r near zero despite a strong relationship. Always look at the scatter plot before trusting a single number.