How strongly are two things related?
Pearson's r, Spearman's ρ and the best-fit line of paired data, on a live scatter plot.
What you enter stays on your device while you use this tool. Opening a shared link sends the settings in its address to HowToolbox to prepare the page.
Separate with spaces, line breaks or semicolons.
Same count as x, paired in order.
Pearson r
0.976
A strong positive relationship (r = 0.976): y rises with x. The best-fit line y = 3.673x + 47.6 explains 95.3% of the variation in y.
Scatter plot with the best-fit line
Key values as a table
| x | y | Line y | Residual |
|---|---|---|---|
| 1 | 52 | 51.27 | 0.7273 |
| 2 | 55 | 54.95 | 0.05455 |
| 3 | 61 | 58.62 | 2.382 |
| 4 | 58 | 62.29 | −4.291 |
| 5 | 68 | 65.96 | 2.036 |
| 6 | 70 | 69.64 | 0.3636 |
| 7 | 69 | 73.31 | −4.309 |
| 8 | 79 | 76.98 | 2.018 |
| 9 | 80 | 80.65 | −0.6545 |
| 10 | 86 | 84.33 | 1.673 |
Correlation and line
- Pairs
- 10
- Pearson r
- 0.976
- Spearman ρ
- 0.976
- Best-fit line
- y = 3.673x + 47.6
- Slope
- 3.673 ± 0.2881
- Intercept
- 47.6 ± 1.787
- R²
- 0.9531
- Residual standard deviation
- 2.616
- p-value (r = 0)
- < 0.001
- y on the line at x = 5.5
- 67.8
Pearson's r, Spearman's ρ and the best-fit line of paired data, on a live scatter plot.
How to use
- Paste the x values in the first box and the matching y values in the second, in the same order; a column copied from a spreadsheet works.
- Read Pearson's r and the sentence under it; the scatter plot shows each pair, the best-fit line and how far each point lies from it.
- Drag the point on the line, or use the arrow keys on it, to read the line's y at any x.
How it works
Correlation measures how closely two quantities move together along a straight line. Pearson's r runs from −1 (a perfect falling line) through 0 (no linear pattern) to +1 (a perfect rising line). Spearman's ρ is the same calculation on the ranks of the values, so it measures any steady rise or fall, not just a straight one, and is less affected by a single extreme point.
The best-fit line y = a + b·x is the one that makes the squared vertical distances to the points (the residuals) as small as possible: b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)², a = ȳ − b·x̄, where x̄ and ȳ are the means. R², the square of r, is the share of the variation in y that the line accounts for. For the example, hours of study 1 to 10 against exam scores, b = 303 ÷ 82.5 ≈ 3.67 points per hour, a ≈ 47.6 and r ≈ 0.976, so the line explains about 95 % of the spread in scores. The methods follow the NIST/SEMATECH e-Handbook of Statistical Methods.
The p-value tests whether the true correlation could be zero, using t = r√((n − 2) ÷ (1 − r²)) with n − 2 degrees of freedom. A strong correlation does not show that one thing causes the other, a curved relationship can have r near 0, and a line should not be trusted far outside the range of the data.
Worked example
What are the best-fit line and the correlation for x = 1 2 3 4 5 and y = 2 4 5 4 5?
- The means are x̄ = 3 and ȳ = 4.
- The slope is b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)² = 0.6, and the intercept is a = ȳ − b·x̄ = 2.2.
- Pearson's r = 0.77, so R² = 60%.
y = 2.2 + 0.6·x with r = 0.77: the line accounts for 60% of the variation in y.
Sources
- NIST Statistical Reference Datasets: Norris (linear regression)Used for: reference data
- NIST/SEMATECH e-Handbook of Statistical Methods: §4.1.4.1 Linear Least Squares RegressionUsed for: formula
Frequently asked questions
What is a strong correlation?
As a rule of thumb, |r| above 0.7 is strong, 0.3 to 0.7 moderate, 0.1 to 0.3 weak and below 0.1 negligible. What counts as strong also depends on the field: in physics r = 0.9 can be poor, in social science r = 0.4 can matter.
What happens if some cells are not numbers?
The calculator leaves out the whole pair containing a non-number and lists the rejected entry. Check the remaining pairs, since dropping observations can change the relationship.
Should I sort my two columns first?
Keep each x value beside its matching y value. Sorting either column separately changes the pairs and can create a misleading correlation.
Why is no correlation shown when every y value is the same?
Correlation needs variation in both quantities. A constant y still gives a horizontal fitted line, but Pearson’s r and Spearman’s ρ are undefined.
How many pairs can I enter?
Enter between 3 and 500 matching pairs. A small sample can give an unstable result, so inspect the scatter plot as well as the coefficient.
Next you might need
More in Math & numbers
- Percentage calculator, private, runs on your device
- Area of shapes, private, runs on your device
- Circle calculator, private, runs on your device
- Combinations and permutations calculator, private, runs on your device
- Complex number calculator, private, runs on your device
- Factorial, private, runs on your device





