# What is the correlation coefficient?

Computes Pearson’s correlation coefficient r between paired x and y values, with r², the t statistic and the p-value of the test that the correlation is 0.

- Page: https://www.acalculator.org/statistics/correlation-coefficient-calculator
- JSON spec: https://www.acalculator.org/statistics/correlation-coefficient-calculator.json
- Version: 8f34a7a4325f

## Default answer

Example with the default inputs (x values [1, 2, 3, 4, 5, 6], y values [2, 4, 5, 4, 5, 7]): For your 6 pairs, the correlation coefficient is r = 0.87831 (r² = 0.771429).

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| x | x values | The first variable: one number per pair, in order. |
| y | y values | The second variable: one number per pair, in the same order as x. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| r | Correlation coefficient r | Pearson’s r, from −1 (a perfect falling line) to 1 (a perfect rising line); 0 is no straight-line link. |
| r2 | r² (coefficient of determination) | r squared: the share of the variation in y that a straight line in x explains. |
| direction | Direction | Positive when y tends to rise with x, negative when it falls, none when r = 0. |
| n | Pairs (n) | How many (x, y) pairs there are. |
| t | t statistic | r √(n − 2) ÷ √(1 − r²), on n − 2 degrees of freedom; left out when r = ±1 or n = 2. |
| p | p-value (two-tailed) | The chance of an \|r\| at least this large if the true correlation is 0; needs at least 3 pairs. |
| df | Degrees of freedom | The degrees of freedom of the test: n − 2. |
| slope | Slope of the best-fit line | Sxy ÷ Sxx: how much y changes for each 1 of x, on the least-squares line. |
| intercept | Intercept of the best-fit line | ȳ − slope × x̄: the line’s y at x = 0. |

## Method

r = Sxy ÷ √(Sxx × Syy), with Sxx = Σ(x − x̄)², Syy = Σ(y − ȳ)², Sxy = Σ(x − x̄)(y − ȳ); t = r √(n − 2) ÷ √(1 − r²).

## Assumptions

- The first x goes with the first y, and so on, so both lists must be the same length (2 to 10,000 pairs).
- r measures a straight-line link only; a strong curved link can still give r near 0.
- The p-value assumes the pairs are independent and the data are roughly normal.

## Worked examples

1. x = 1 or 2, y = 2 or 4 gives r = 0.87831, r2 = 0.771429, n = 6, t = 3.674235, p = 0.021312, slope = 0.771429, intercept = 1.8. Source: NIST Dataplot Reference Manual, CORRELATION: r = Sxy ÷ (√Sxx √Syy); significance from (N − 2) r² ÷ (1 − r²) on the F distribution (https://itl.nist.gov/div898/software/dataplot/refman2/auxillar/correlat.htm, retrieved 2026-10-02).
2. x = 0.2 or 337.4, y = 0.1 or 338.8 gives r2 = 0.999994, slope = 1.002117, intercept = -0.262323, n = 36. Source: NIST StRD linear least squares dataset Norris, certified R-squared 0.999993745883712 (https://www.itl.nist.gov/div898/strd/lls/data/LINKS/v-Norris.shtml, retrieved 2026-10-02) (certified values to 15 digits).
3. x = 1 or 2, y = 9 or 6 gives r = -1, r2 = 1, p = 0, direction = Negative. Source: NIST Dataplot Reference Manual, CORRELATION: r = Sxy ÷ (√Sxx √Syy); significance from (N − 2) r² ÷ (1 − r²) on the F distribution (https://itl.nist.gov/div898/software/dataplot/refman2/auxillar/correlat.htm, retrieved 2026-10-02).
4. x = 1 or 2, y = 1 or 3 gives r = 0, r2 = 0, t = 0, p = 1, direction = None (r = 0). Source: NIST Dataplot Reference Manual, CORRELATION: r = Sxy ÷ (√Sxx √Syy); significance from (N − 2) r² ÷ (1 − r²) on the F distribution (https://itl.nist.gov/div898/software/dataplot/refman2/auxillar/correlat.htm, retrieved 2026-10-02).

## FAQ

### How do I calculate the correlation coefficient?

Find the means x̄ and ȳ. Then Sxx = Σ(x − x̄)², Syy = Σ(y − ȳ)² and Sxy = Σ(x − x̄)(y − ȳ), and r = Sxy ÷ √(Sxx × Syy). For x = 1 to 6 and y = 2, 4, 5, 4, 5, 7: Sxx = 17.5, Syy = 13.5, Sxy = 13.5, so r = 0.878.

### What does the correlation coefficient tell me?

How closely the points follow a straight line, and in which direction. r = 1 is a perfect rising line, r = −1 a perfect falling line, and r near 0 means no straight-line link.

### What is r²?

r squared, the coefficient of determination: the share of the variation in y that a straight line in x explains. r = 0.878 gives r² = 0.771, so the line explains about 77% of the variation.

### Is the correlation significant?

The p-value answers that: it is the chance of an |r| at least this large if there were no correlation. With 6 pairs and r = 0.878, p = 0.0213, below 0.05. With few pairs, even a large r may not be significant.

### Does correlation mean causation?

No. Two things can rise together because a third thing drives both, or by chance. A correlation shows a link, not what causes it.

### Why is r 0 when my points make a clear curve?

Pearson’s r only measures straight-line links. Points on a hump, such as 1, 3, 3, 1, have r = 0 even though y depends on x.

## Sources

- NIST Dataplot Reference Manual, CORRELATION (Sxx, Syy, Sxy and r = Sxy ÷ (√Sxx √Syy); significance from (N − 2) r² ÷ (1 − r²) on the F distribution), retrieved 2026-10-02. https://itl.nist.gov/div898/software/dataplot/refman2/auxillar/correlat.htm
- NIST Statistical Reference Datasets, linear least squares dataset Norris, certified values (R-squared 0.999993745883712, B1 1.00211681802045, B0 −0.262323073774029), retrieved 2026-10-02. https://www.itl.nist.gov/div898/strd/lls/data/LINKS/v-Norris.shtml
