Coefficient of Correlation Calculator

Paste two columns to get Pearson's r or Spearman's rank correlation, with r-squared, the sample size, and a significance test on r.

Paste two columns. One number per row, the same number of rows in each.

Coefficient
Significance test

Correlation coefficient

Paste two columns

A result appears here after you run the tool.

Export

r = Sxy / sqrt(Sxx * Syy); t = r * sqrt((n - 2) / (1 - r²)) How?

How this is calculated

The coefficient is the centered covariance divided by the product of the standard deviations, so it is bounded to the range -1 to 1. r² is the square of that coefficient and, in Pearson mode, is the share of variance the linear fit explains. The worked-values block shows the means and the three sums of squares (Sxx, Syy, Sxy) that feed the ratio, and the significance block shows the t statistic with its degrees of freedom.

Formula: r = Sxy / sqrt(Sxx * Syy); t = r * sqrt((n - 2) / (1 - r²))

Which coefficient to run

Pearson's r measures the strength of a straight-line relationship between two variables. Spearman's rho ranks each column first, then correlates the ranks, so it captures any monotonic trend and reads a consistently curved relationship at close to full strength. Choose Pearson for linear association and Spearman when the relationship is ordered but bends.

Method and conventions

Significance uses Student's t with df = n - 2 and t = r sqrt((n - 2) / (1 - r²)), the same statistic as the slope test in a simple linear regression. For Pearson's r this t follows an exact t distribution under the null hypothesis of zero correlation when the two variables are bivariate normal, and is a large-sample approximation otherwise. For Spearman's rho the tool applies the same statistic to the ranks, but there it is asymptotic: the exact null distribution of rho is discrete and only approaches the t distribution as n grows, so the reported p-value is approximate and is least reliable at small n or with many ties. A permutation test on the ranks is the exact alternative for small samples. Spearman uses the average-rank Pearson method: tied values share the mean of the ranks they span, which the popular 1 - 6*sum(d²)/(n(n²-1)) shortcut gets wrong whenever ties are present. p-values are computed from the t distribution CDF, shown to four decimals and floored at p < .0001. In Spearman mode, rho² is labelled shared rank variance rather than a coefficient of determination, because it is not the least-squares R² of the raw data.

Why there is no sample-versus-population switch

The n against n - 1 divisor cancels in the ratio that defines r, so both conventions return the same coefficient. A toggle would change nothing, so the tool omits it.

Sources

  1. Pearson correlation coefficient. Wikipedia. Retrieved .
  2. Quantitative techniques, correlation (e-Handbook 1.3.5.11). NIST/SEMATECH. Retrieved .
  3. Testing the significance of the correlation coefficient (Introductory Statistics 1e, 12.5). LibreTexts / OpenStax. Retrieved .
  4. Spearman's rank correlation coefficient. Wikipedia. Retrieved .