Math · Statistics
Correlation coefficient calculator.
Paste your x and y pairs, one pair per line, to get Pearson r, r squared, the t statistic and a p-value. Your data stays in this browser.
For OpenStax's 11 pairs of third-exam and final-exam scores, Pearson r = 0.6631, so r² = 0.4397. The t statistic is 2.6576 on 9 degrees of freedom and the two-tailed p-value is 0.0262.
The formula
With deviations from the means, r = Sxy / √(Sxx × Syy), where Sxy = Σ(x − x̄)(y − ȳ), Sxx = Σ(x − x̄)² and Syy = Σ(y − ȳ)². r runs from −1 to +1. Its square, r², is the coefficient of determination: OpenStax interprets it as the percent of the variation in y that is explained by the linear relationship with x.
To test whether the true correlation is zero, convert r to t = r √((n − 2) / (1 − r²)). For pairs from an uncorrelated bivariate normal distribution, t follows Student’s t distribution with n − 2 degrees of freedom, which gives the two-tailed p-value.
Worked example
The default data are the OpenStax example of 11 students’ third-exam score (x, out of 80) and final-exam score (y, out of 200). The calculator returns r = 0.6631 and r² = 0.4397, matching OpenStax’s r = 0.6631 and r² = 0.4397 (about 44% of the variation in final-exam grades). Then t = 0.6631 × √(9 / 0.5603) = 2.6576, and with 9 degrees of freedom the two-tailed p-value is 0.0262.
Limits
r only measures how well a straight line describes the data. A strong curve can give r near 0, a single extreme point can swing r a lot, and a high r does not show that x causes y. Always look at the scatter plot. The p-value assumes independent pairs and, strictly, bivariate normal data.
Sources, opened 8 October 2026: OpenStax Introductory Statistics 2e, 12.3 The Regression Equation (third-exam and final-exam data, r = 0.6631, r² = 0.4397 and its interpretation); Wikipedia, Pearson correlation coefficient (the t statistic and its t distribution with n − 2 degrees of freedom under the null of zero correlation).
Frequently asked questions
How do you calculate the correlation coefficient?
Subtract each variable's mean, multiply the deviations for each pair and add them up (S_xy), then divide by the square root of S_xx times S_yy. This calculator does that for any list of x and y pairs.
What does r squared tell me?
r squared is the square of r. For the example data r = 0.6631 and r squared = 0.4397, which OpenStax reads as about 44% of the variation in the final-exam grades being explained by the linear relationship with the third-exam score.
How is the p-value for r calculated?
The calculator forms t = r x sqrt((n - 2) / (1 - r squared)) and looks it up in Student's t distribution with n - 2 degrees of freedom. For the example, t = 2.6576 with 9 degrees of freedom gives a two-tailed p-value of 0.0262.
Does a high correlation mean x causes y?
No. Correlation measures how closely the points follow a straight line. Two variables can be strongly correlated because of a third factor or by chance, so the number alone does not show cause.
How many pairs do I need?
The calculator needs at least three pairs, because the test has n - 2 degrees of freedom. With very few pairs r is unstable, and one unusual pair can change it a lot.
Can I get the regression line too?
Yes. The linear regression calculator on this site uses the same pairs and gives the slope, intercept and a prediction.
Learning aid, not for decisions
Educational calculator. Results assume the conditions listed on this page, which real data often only roughly meet. Do not use it for clinical, regulatory, legal or financial decisions.