# 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.

- Calculator id: `correlation` · Category: Statistics & Probability (`statistics`) · Tool name: `calculate_correlation`
- Canonical page: https://tttkmbb.com/statistics/correlation · This document: https://tttkmbb.com/statistics/correlation.md · JSON definition: https://tttkmbb.com/statistics/correlation.json

## Purpose

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.

**Use when:** 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).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `x_values` | number_list |  | required | Independent (explanatory) variable, one number per observation. |
| `y_values` | number_list |  | required | Dependent (response) variable, in the same order as x_values. |

## Output

| Field | 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. |

## 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.

## Data Sources

- Wikipedia – Pearson correlation coefficient — https://en.wikipedia.org/wiki/Pearson_correlation_coefficient (reference, retrieved 2026-09-23)
- NIST/SEMATECH e-Handbook of Statistical Methods, 4.1.4.1 Linear Least Squares Regression — https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd141.htm (government, retrieved 2026-09-23)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/correlation?x_values=…&y_values=…`
- `POST https://tttkmbb.com/api/v1/calculate/correlation` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/correlation · OpenAPI operationId `calculate_correlation` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "correlation", "inputs": {…}}`

## Example

- x = 1..5, y = 2, 4, 5, 4, 5: inputs `{"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: inputs `{"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
```

## Limitations

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). 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. All values are computed from the formula above; no measurement or live data is involved.

## 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

- [Linear Regression Calculator](https://tttkmbb.com/statistics/linear-regression.md) — Fit the least-squares line and predict y from x.
- [Descriptive Statistics Calculator](https://tttkmbb.com/statistics/descriptive-statistics.md) — Summary statistics of a single variable.
