Correlation Coefficient Calculator
Pearson’s correlation coefficient (r) quantifies the linear relationship between two variables, how closely they move together. This calculator takes paired X/Y values and computes r and r-squared (the proportion of variance explained), along with the number of pairs used.
How to calculate correlation
-
1
Paste paired data
One X value and one Y value per row, comma- or tab-separated. Or paste from a spreadsheet.
-
2
Run the calculation
The calculator pairs them, computes means, deviations, and the Pearson formula.
-
3
Read r and r²
r ranges from -1 to +1. r² is its square, interpretable as percentage of shared variance.
-
4
Note the sample size
Check the number of pairs (n) shown with the results. Small samples make r unreliable, so report n alongside r.
The formula
r = Σ((xᵢ - x̄)(yᵢ - ȳ)) / √(Σ(xᵢ - x̄)² × Σ(yᵢ - ȳ)²)
Equivalently: r = cov(X, Y) / (σ_X × σ_Y). It is the covariance normalised by the product of the standard deviations, which forces the result into [-1, +1].
Interpreting r
| r value | Linear relationship |
|---|---|
| ±0.9 to ±1.0 | Very strong |
| ±0.7 to ±0.9 | Strong |
| ±0.5 to ±0.7 | Moderate |
| ±0.3 to ±0.5 | Weak |
| ±0.0 to ±0.3 | Very weak or none |
r² (coefficient of determination) is the fraction of variance in Y explained by a linear model in X. r = 0.7 means r² = 0.49, about half the variance is linear, half is not.
When Pearson is the wrong tool
Pearson assumes a linear relationship with roughly normal data and no big outliers. It fails badly on:
- Curved relationships: y = x² over the range [-5, 5] has r = 0 despite being perfectly predictable.
- Outliers: a single point 5 standard deviations out can double or halve r.
- Rank data: use Spearman’s ρ (correlation of ranks) instead.
- Binary or categorical: use point-biserial, phi, or Cramer’s V depending on types.
Correlation is not causation: the classic
Two variables can correlate strongly because:
- X causes Y.
- Y causes X.
- A third variable Z causes both (confounding).
- Pure chance (in small samples).
- Selection bias in how the data was collected.
Ice cream sales and drowning deaths correlate +0.8 over summer months. Ice cream does not cause drowning, hot weather causes both.
Sample size and significance
A small-sample r can be misleading. For n = 5, r = 0.5 is not statistically distinguishable from zero (p ≈ 0.4). For n = 100, r = 0.2 is clearly non-zero (p < 0.05). Always report the sample size alongside r. A p-value for r tests the null hypothesis that the true correlation is zero.
Frequently Asked Questions
A moderate positive linear relationship. r² = 0.25, so about 25% of the variance in Y is explained linearly by X; 75% is unexplained. That is a real effect but far from deterministic.
No, by construction. If your output is outside [-1, 1] the calculation has a bug, typically from mis-paired data or from computing covariance without normalising by the standard deviations.
Pearson for linear relationships in continuous data with no big outliers. Spearman (correlation of ranks) for monotonic but non-linear relationships or when outliers are pulling Pearson around.
No. It is a description of the sample you have, not a prediction. Cross-validation, a held-out test set, or a confidence interval on r are the honest ways to check stability.
Related Tools
BMI Calculator
Calculate body mass index from height and weight. Shows WHO category, healthy-weight range and limitations of BMI.
Social Security Calculator
Estimate a US Social Security retirement benefit from your PIA and claiming age. Compare monthly and annual amounts at 62, FRA 67 and 70.
Age Calculator
Calculate exact age in years, months and days from a birth date, plus total days, hours and the next birthday countdown.
Amp-Hour Calculator
Work out battery runtime and stored energy from amp-hours, voltage and load current. Get runtime in hours and minutes plus energy in watt-hours and kilowatt-hours.
Dog Age Calculator
Convert your dog's age to human years using modern veterinary research. Breed-size aware: small, medium and large dogs age differently.
Scientific Calculator
Evaluate supported real-number expressions with trig, logs, powers and parentheses locally in your browser.