Correlation Coefficient Calculator

Share calculator:
Embed this tool:

Paste paired X and Y values, choose Pearson, Spearman or Kendall, and get the coefficient together with its Z score, one-sided p-value, confidence intervals and the least-squares line.

How to use the calculator

  1. Enter one pair per row, X first and Y second, separated by a space, a tab or a comma. Pasting two spreadsheet columns works.
  2. Choose the coefficient: Pearson's r for a linear relationship between measured values, Spearman's r or Kendall's τ for ranks or a monotonic but not necessarily straight relationship.
  3. Set the confidence level (95% by default) and press Calculate.

At least four pairs are needed, and each row must contain exactly two numbers. The output lists the coefficient, a Z score, a one-sided p-value, a two-sided confidence interval, right-sided and left-sided intervals, the number of pairs and the least-squares regression line. For Spearman and Kendall the regression line is fitted to the ranks of the data, not the raw values.

The p-value tests the hypothesis that the true coefficient is zero or in the opposite direction to the one observed. A positive coefficient is tested against "≤ 0" and a negative one against "≥ 0", so the p-value is always the probability in the direction of the effect.

What a correlation coefficient tells you

A correlation coefficient condenses the relationship between two variables into one number between −1 and +1. The sign gives the direction: positive means that X and Y rise together, negative means that one rises as the other falls. The distance from zero gives the strength, and 0 means no association of the kind the coefficient measures.

Informal reading of the absolute value (conventions differ between fields)
|coefficient|Common description
0.00 to 0.19very weak or none
0.20 to 0.39weak
0.40 to 0.59moderate
0.60 to 0.79strong
0.80 to 1.00very strong

For Pearson's r, the square of the coefficient, r², is the share of the variance in Y that a straight line on X accounts for. A correlation can be statistically significant and still too small to matter, so read the size and the interval, not only the p-value.

Pearson, Spearman or Kendall?

Pearson's rSpearman's rKendall's τ
Works onvaluesranks of the valuespairwise orderings
Relationship detectedlinearany monotonicany monotonic
Sensitive to outliersyeslittlelittle
Data typesinterval or ratioordinal, interval, ratioordinal, interval, ratio
Typical usemeasurements that follow a straight lineratings, skewed datasmall samples, many ties

None of the three requires both variables to be normally distributed for the coefficient itself to be valid. The Fisher-transformation intervals and p-values do lean on normal-theory approximations, so for very small samples treat them as rough guides. You can screen a variable with the normality test calculator.

Formulas

Pearson's r is the covariance of the two variables divided by the product of their standard deviations:

r = Σ (xᵢ − x̄)(yᵢ − ȳ) ÷ √[ Σ (xᵢ − x̄)² × Σ (yᵢ − ȳ)² ]

Spearman's r is Pearson's r applied to the ranks of the data. Tied values share the average of the ranks they span. With no ties it reduces to 1 − 6 Σ d² ÷ (n(n² − 1)), where d is the difference between the two ranks of a pair.

Kendall's τ compares every pair of observations. The version used here, τ-b, adjusts for ties:

τ = (C − D) ÷ √[ (N − T_x)(N − T_y) ]C and D are concordant and discordant pairs, N = n(n − 1) ÷ 2, and T_x and T_y count pairs tied in X or in Y.

Confidence intervals for Pearson's and Spearman's coefficients use the Fisher transformation z′ = ½ ln[(1 + r) ÷ (1 − r)], which is approximately normal with standard error 1 ÷ √(n − 3) for Pearson. The interval is computed on the z′ scale and transformed back with the hyperbolic tangent:

r_low, r_high = tanh( z′ ∓ z_(α/2) ÷ √(n − 3) )

For Spearman the standard error is inflated to √(1.06 ÷ (n − 3)). The Z score is z′ divided by that standard error, and the p-value is the one-sided normal tail beyond it. Kendall's τ uses a normal approximation of its own, with bounds capped at −1 and +1.

Worked example

Suppose eight students record weekly study hours (X = 1, 2, 3, 4, 5, 6, 7, 8) and their test scores (Y = 52, 55, 61, 60, 68, 72, 70, 81). The means are 4.5 and 64.875. The sums of squares and cross-products are Sxx = 42, Syy = 648.875 and Sxy = 159.5.

r = 159.5 ÷ √(42 × 648.875) = 159.5 ÷ 165.09 ≈ 0.9662

The Fisher transform is z′ = atanh(0.9662) ≈ 2.0313 and the standard error is 1 ÷ √5 ≈ 0.4472. A 95% interval on that scale is 2.0313 ± 1.96 × 0.4472, which is 1.1548 to 2.9078. Transforming back gives 0.8193 to 0.9941. The Z score is 2.0313 × √5 ≈ 4.54, with a one-sided p-value of about 0.0000028.

The regression line is y = 3.7976 x + 47.786, so each extra study hour goes with about 3.8 more points. The same data give Spearman's r = 0.9524 and Kendall's τ = 0.8571, both a little lower because they only use the order of the values, and r² = 0.934 says that about 93% of the score variation lines up with study time.

Pitfalls

  • Correlation is not causation. Two variables can move together because of a third factor or by coincidence.
  • Outliers can make or break Pearson's r. Plot the data first; one extreme point can create a strong correlation or hide one.
  • Restricted ranges shrink r. Looking only at students who scored between 60 and 70 would show a much weaker relationship than the full range.
  • Non-linear patterns can hide. A curve can have a Pearson correlation near zero while the two variables are tightly linked; a Spearman or Kendall coefficient will catch a monotonic curve.
  • Do not extrapolate the line. The regression line describes the range of your data only.

Small samples give wide intervals. With only four or five pairs a high coefficient can arise by chance, so look at the confidence interval as well as the coefficient. For the spread of a single variable use the standard deviation calculator.

Frequently asked questions

How many data pairs do I need?

The calculator needs at least four pairs, because the Fisher transformation uses n − 3 in its standard error. In practice you want considerably more; with fewer than about 20 pairs the intervals are very wide.

What is the difference between Pearson and Spearman correlation?

Pearson's r measures how well a straight line fits the actual values. Spearman's r is Pearson's r computed on the ranks, so it measures how consistently one variable increases with the other, whether or not the pattern is a straight line, and it is much less affected by outliers.

Does a correlation of zero mean the variables are unrelated?

No. It means there is no relationship of the type the coefficient detects. Pearson's r can be zero for a perfect U-shaped relationship.

Why does a perfect correlation sometimes show nan for the Z score?

At exactly +1 or −1 the Fisher transformation is infinite, and tiny floating-point rounding in the calculation can push r just past the limit, which makes the logarithm undefined. A perfect fit is a degenerate case, so treat the interval and p-value as meaningless there.

References

  1. Pearson, K. (1896). Mathematical contributions to the theory of evolution. III. Regression, heredity, and panmixia. Philosophical Transactions of the Royal Society A, 187, 253-318
  2. Spearman, C. (1904). The proof and measurement of association between two things. American Journal of Psychology, 15(1), 72-101
  3. Kendall, M.G. (1938). A new measure of rank correlation. Biometrika, 30(1-2), 81-93
  4. Fieller, E.C., Hartley, H.O. and Pearson, E.S. (1957). Tests for rank correlation coefficients. I. Biometrika, 44(3-4), 470-481

Cite this calculator and page

If you use this page in your work, you can cite it as:

Reeliy Editorial Team. (2026). Correlation Coefficient Calculator. Reeliy. https://reeliy.com/calculators/correlation-coefficient-calculator“Correlation Coefficient Calculator.” Reeliy, 2026, https://reeliy.com/calculators/correlation-coefficient-calculator.