Home › Statistics & 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
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
x_values | number_list | yes | Independent (explanatory) variable, one number per observation. | |
y_values | number_list | yes | Dependent (response) variable, in the same order as x_values. |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
sample_size | integer | Number of (x, y) pairs. | |
pearson_r | number | Linear correlation coefficient between −1 and 1. | |
r_squared | number | Coefficient of determination: fraction of the variance in y explained by a linear relationship with x. | |
covariance | number | Σ(x − x̄)(y − ȳ) / (n − 1). | |
interpretation | string | Strength (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
- API:
GET https://tttkmbb.com/api/v1/calculate/correlation(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/correlation · Markdown: https://tttkmbb.com/statistics/correlation.md · JSON definition: https://tttkmbb.com/statistics/correlation.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="correlation" - OpenAPI operationId:
calculate_correlation - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
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
- Linear Regression Calculator — Fit the least-squares line and predict y from x.
- Descriptive Statistics Calculator — Summary statistics of a single variable.