Correlation Coefficient Equation Calculator
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
This calculator works out the Pearson correlation coefficient (r) from two lists of paired numbers, showing how strongly and in what direction two variables move together. You enter your x-values and y-values into the two lists, and the calculator returns r, the coefficient of determination (r²), and the number of pairs. The result is a number between −1 and +1, where −1 means a perfect negative linear relationship, +1 a perfect positive one, and 0 no linear relationship.
Formula
The Pearson correlation coefficient is calculated with this formula:
r = [n·Σxy − (Σx)(Σy)] / √{[n·Σx² − (Σx)²]·[n·Σy² − (Σy)²]}
Where:
- n = number of paired observations (count of x values, which must equal the count of y values)
- Σxy = sum of the products of each x multiplied by its paired y
- Σx = sum of all x values
- Σy = sum of all y values
- Σx² = sum of each x value squared
- Σy² = sum of each y value squared
The formula measures how much the two variables vary together (covariance) relative to how much they vary separately. It is unitless, so it does not matter what units your data are in—inches, dollars, or test scores all work.
Worked Example
Using the default values from the calculator: x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 5.
- Count: n = 5
- Σx = 1 + 2 + 3 + 4 + 5 = 15
- Σy = 2 + 4 + 5 + 4 + 5 = 20
- Σxy = (1×2) + (2×4) + (3×5) + (4×4) + (5×5) = 2 + 8 + 15 + 16 + 25 = 66
- Σx² = 1 + 4 + 9 + 16 + 25 = 55
- Σy² = 4 + 16 + 25 + 16 + 25 = 86
- Numerator = 5×66 − 15×20 = 330 − 300 = 30
- Denominator = √[(5×55 − 15²) × (5×86 − 20²)] = √[(275 − 225) × (430 − 400)] = √[50 × 30] = √1500 ≈ 38.7298
- r = 30 / 38.7298 ≈ 0.7746
So r ≈ 0.7746, and r² ≈ 0.6000. This indicates a strong positive linear relationship—as x increases, y tends to increase, though not perfectly.
When to Use the Pearson Correlation
Use this coefficient when you want to measure the strength and direction of a linear relationship between two continuous variables. Common applications include:
- Comparing test scores and study hours
- Examining the relationship between temperature and energy use
- Checking if height and weight move together in a sample
- Validating that two measurement methods give consistent results
Pearson r only captures straight-line relationships. If the true relationship is curved (e.g., quadratic), r may be near zero even when a strong pattern exists. Always plot your data first to see the shape.
How to Read the Result
The sign of r tells you the direction:
- r > 0: positive relationship—as one variable increases, the other tends to increase.
- r < 0: negative relationship—as one increases, the other tends to decrease.
- r = 0: no linear relationship (but there could still be a non-linear one).
The magnitude tells you strength:
- |r| ≥ 0.8: very strong
- |r| between 0.5 and 0.8: moderate to strong
- |r| between 0.2 and 0.5: weak to moderate
- |r| < 0.2: very weak
r² (coefficient of determination) is often more interpretable: it is the proportion of variance in one variable that is predictable from the other. For example, r = 0.7746 gives r² = 0.60, meaning 60% of the variation in y is explained by its linear relationship with x.
Common Mistakes and Misconceptions
Correlation does not imply causation. A high r between ice cream sales and drowning deaths does not mean ice cream causes drowning—both are driven by summer heat. This is the most common error.
Other frequent mistakes:
- Using unequal list lengths: the calculator requires the same number of x and y values. If one list is shorter, the extra values are ignored or an error appears.
- Ignoring outliers: a single extreme point can inflate or deflate r dramatically. Always check a scatterplot.
- Mixing up sample vs. population: Pearson r is the same formula for both, but significance tests differ. This calculator gives the coefficient only, not a p-value.
- Assuming linearity: r near zero does not mean “no relationship�—it means no straight-line relationship.
- Rounding too early: keep at least 4 decimal places during intermediate steps to avoid rounding errors.
Limitations of the Formula
The Pearson coefficient is sensitive to outliers and assumes that the relationship is linear and that the data are roughly normally distributed for inference (though the calculation itself does not require normality). It also requires that both variables are measured on an interval or ratio scale—not ordinal or nominal. For ranked data, use Spearman’s rank correlation instead.
Another limitation: r is dimensionless, so it cannot tell you the slope of the relationship. Two datasets can have the same r but very different slopes. The slope is given by linear regression, which is a separate calculation.
Alternatives to Pearson r
Depending on your data, one of these may be more appropriate:
- Spearman’s rank correlation: uses ranks instead of raw values; works for ordinal data or when the relationship is monotonic but not linear.
- Kendall’s tau: another rank-based measure, more robust to outliers and better for small samples with many ties.
- Point-biserial correlation: used when one variable is continuous and the other is dichotomous (e.g., pass/fail).
- Polychoric correlation: for two ordinal variables assumed to have an underlying continuous distribution.
- Partial correlation: measures the relationship between two variables while controlling for a third.
If your data show a clear curve, try fitting a polynomial or other non-linear model instead of using r.
Frequently Asked Questions
What does a correlation coefficient of 0.5 mean? It means a moderate positive linear relationship. About 25% (0.5²) of the variance in one variable is explained by the other. It does not mean that half the points lie on a straight line—it is a measure of scatter around the best-fit line.
Can I use this calculator for only 3 pairs of numbers? Yes, the formula works with any n ≥ 2. However, with very small samples, the coefficient is unreliable and highly sensitive to a single point. A sample size of at least 10–15 is usually recommended before interpreting r as meaningful.
What is the difference between r and r²? r is the correlation coefficient itself, ranging from −1 to +1. r² is the coefficient of determination, ranging from 0 to 1, and represents the proportion of shared variance. For example, r = 0.8 gives r² = 0.64, meaning 64% of the variation in one variable is explained by the other.
Does the calculator work with negative numbers? Yes, negative values are fine. The formula handles them naturally. Just ensure your lists are comma-separated and have the same length.
What if my data has an outlier? The Pearson r can be drastically changed by one outlier. For example, a single extreme point can turn a weak positive correlation into a strong one. Always plot your data. If outliers are present, consider Spearman’s rank correlation, which is more robust.
Is this the same as the correlation coefficient in Excel? Yes, Excel’s CORREL function uses the same Pearson formula. This calculator gives the same result, but also provides r² and the pair count, which Excel does not directly show.
Related
Formula used
in x | X values (comma separated) | - | 1, 2, 3, 4, 5 | 0 in y | Y values (comma separated) | - | 2, 4, 5, 4, 5 | 0 out r | Correlation coefficient r | - | (n * sum(x*y) - sum(x)*sum(y)) / sqrt((n*sum(x^2) - sum(x)^2) * (n*sum(y^2) - sum(y)^2)) | 4 out r2 | Coefficient of determination r² | - | r^2 | 4 out n | Number of pairs | - | count(x) | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.