HomeStatistics & Probability › Correlation Coefficient Calculator

Correlation Coefficient Calculator

Computes the Pearson product-moment correlation coefficient r, the coefficient of determination r², and the sample covariance for two paired lists of numbers, with a strength/direction interpretation.

When to use

You have paired measurements of two numeric variables and want to quantify the strength and direction of their linear relationship.

Do not use when: You need the fitted line or predictions (use linear-regression), the relationship is clearly non-linear or the data are ranks/ordinal (Spearman's rank correlation is more appropriate), or you only have one variable (use descriptive-statistics).

Formula

r = Σ(x − x̄)(y − ȳ) / √(Σ(x − x̄)² · Σ(y − ȳ)²); r² = r × r; covariance = Σ(x − x̄)(y − ȳ) / (n − 1)

Pearson's r measures linear association only; the strength bands follow the common convention (Evans 1996) and are a rough guide, not a significance test. r is undefined when either variable is constant.

Inputs

ParameterTypeUnitRequiredDescription
x_valuesnumber_listyesIndependent (explanatory) variable, one number per observation.
y_valuesnumber_listyesDependent (response) variable, in the same order as x_values.

Outputs

OutputTypeUnitDescription
sample_sizeintegerNumber of (x, y) pairs.
pearson_rnumberLinear correlation coefficient between −1 and 1.
r_squarednumberCoefficient of determination: fraction of the variance in y explained by a linear relationship with x.
covariancenumberΣ(x − x̄)(y − ȳ) / (n − 1).
interpretationstringStrength (very weak < 0.2, weak < 0.4, moderate < 0.6, strong < 0.8, very strong ≥ 0.8 in |r|) and direction.

Example

x = 1..5, y = 2, 4, 5, 4, 5: {"x_values":[1,2,3,4,5],"y_values":[2,4,5,4,5]}{"sample_size":5,"pearson_r":0.7746,"r_squared":0.6,"covariance":1.5,"interpretation":"Strong positive linear correlation"}

Perfect negative relationship: {"x_values":[1,2,3,4],"y_values":[10,8,6,4]}{"pearson_r":-1,"r_squared":1,"covariance":-3.3333,"interpretation":"Perfect negative linear correlation"}

GET https://tttkmbb.com/api/v1/calculate/correlation?x_values=1%2C2%2C3%2C4%2C5&y_values=2%2C4%2C5%2C4%2C5

Machine access

Sources

FAQ

Does correlation imply causation?

No. A high |r| shows that the variables move together linearly; it says nothing about which causes which or whether a third variable drives both.

Is a given r statistically significant?

That depends on n: the test statistic t = r·√((n − 2) / (1 − r²)) is compared with a t distribution with n − 2 degrees of freedom. For n = 5, |r| must exceed about 0.88 to be significant at the 5 % level.

Related calculators