Correlation coefficient calculator
The values 1 to 5 paired with 2, 4, 6, 8 and 10 give a Pearson r of exactly 1, a perfect positive straight-line link; reverse the second list and r becomes −1. Paste two equal-length lists to measure how strongly they move together. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- X
- 1, 2, 3, 4, 5
- Y
- 2, 4, 6, 8, 10
- N
- 5
- Resistance (Ω)
- 1
- Mean x
- 3
- Mean y
- 6
This correlation coefficient calculator computes the Pearson product-moment correlation r between two equal-length lists of numbers. You get the paired sample size n, the coefficient r in the closed interval from minus one to plus one when both series have positive variance, the means of x and y, the raw sums and sum of products, the centered sums of squares and cross-product sxx, syy, and sxy, plus sample covariance with Bessel’s correction. Classic checks include the five-point pair series one through five against two, four, six, eight, ten, which yields perfect positive correlation r equals one, and the same x against a reversed y, which yields perfect negative correlation r equals minus one. The engine uses a deterministic two-pass algorithm only: no network calls, no random sampling, and no date-dependent shortcuts.
What Pearson's r measures and what you get
Pearson’s product-moment correlation coefficient measures the strength and direction of a linear relationship between two paired numeric series. After the means of x and y are known, each observation contributes a product of centered residuals; that cross-product sum is scaled by the product of the residual sum of squares on each axis so the result is unitless and lies between minus one and plus one whenever both series vary.
A value near plus one means high values of x tend to travel with high values of y; a value near minus one means they move in opposite directions; a value near zero means there is little linear association even if a nonlinear pattern might still exist. The equal-length and positive-variance rules are intentional: unequal lists would invent pairings, and zero variance would divide by zero.
Where Pearson correlation fits in study, science, and product work
Students meet Pearson r when a textbook contrasts correlation with causation, when a lab report asks whether two sensors move together, or when they need a clean check against a calculator that only prints a rounded r without the intermediate sums. Teachers can pre-generate answer keys for modest paired series without trusting opaque apps that drop pairs on missing cells or switch silently between population and sample covariance conventions.
Developers call the same contract from scripts to seed deterministic test vectors, to validate feature-selection pipelines that rank columns by |r|, or to satisfy data-quality gates that flag pairs whose correlation collapses when one series becomes constant. Analysts use r as a first look at linear association before fitting a regression; a large |r| does not prove a causal link, but a tiny |r| can still coexist with strong nonlinear dependence, so the number is a diagnostic, not a verdict.
Product and operations teams watch correlation between latency and concurrency, basket size and coupon use, or error rate and deploy size to spot regressions that single-variable dashboards would miss. Pair it with standard-deviation tools when you need univariate spread next to bivariate association, and with CSV profiling when you need multi-column summaries rather than two named series.
What you can do with it
Homework and lab checks
Verify Pearson r for textbook paired series and instrument labs with means, residual sums, and sample covariance shown.
Feature and ops screening
Screen linear association between two metrics—latency vs load, spend vs visits—before deeper modeling.
FAQ
What does the correlation coefficient calculator cost?
It is free in your browser on this page.
What is Pearson’s correlation coefficient r?
It is a unitless measure of linear association between two paired series, ranging from −1 to +1 when both series have positive variance. Values near ±1 indicate strong linear association; values near 0 indicate little linear association.
What happens if one series is constant?
If all values in x or in y are identical, that series has zero variance and r is undefined.
Is correlation the same as causation?
No. A high |r| only describes linear co-movement in the given pairs; it does not prove that one variable causes the other.
What does an r close to zero mean?
That there is little straight-line association between the two series. A curved or other nonlinear pattern can still exist, so a value near zero does not prove the two are unrelated.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/stat/correlation \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"x":[1,2,3,4,5],"y":[2,4,6,8,10]}'const res = await fetch("https://api.kit.forhosting.com/stat/correlation", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"x": [
1,
2,
3,
4,
5
],
"y": [
2,
4,
6,
8,
10
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/correlation",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"x": [
1,
2,
3,
4,
5
],
"y": [
2,
4,
6,
8,
10
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/correlation", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"x":[1,2,3,4,5],"y":[2,4,6,8,10]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"x":[1,2,3,4,5],"y":[2,4,6,8,10]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/correlation", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"x": [
1,
2,
3,
4,
5
],
"y": [
2,
4,
6,
8,
10
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.correlation",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_n | 10000 |
max_abs | 1000000000000000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
What Pearson r measures and what the response contains
This calculator always returns a fixed shape: n, r, mean_x, mean_y, sum_x, sum_y, sum_xy, sxx, syy, sxy, sample covariance, a short formula string, and the published maximum length so clients can validate before they send a batch. There is no approximate Monte Carlo path presented as truth and no silent padding when the lists differ: the engine either finishes the two-pass arithmetic inside the supported length and magnitude limits or rejects the input with invalid_input. Rejected cases include a missing x or y field, empty lists, fewer than two pairs, non-finite entries such as Infinity or NaN, non-numeric tokens, unequal series lengths, arrays longer than the published maximum, and any case where all values in x are identical or all values in y are identical so that a variance is zero and r is undefined.
How x and y are read and how the two-pass algorithm stays stable
Each element is parsed as a finite decimal; optional leading signs and scientific notation are allowed, while empty tokens, bare letters, and non-numeric objects fail with a field index in the message so a bad cell does not become a silent zero. Computation is the classic two-pass method: first the means of x and y, then the centered residual products sxy and the residual sums of squares sxx and syy, then r as sxy over the square root of sxx times syy, with sample covariance as sxy over n minus one for convenience next to the correlation. Returning the intermediate sums makes it easy to audit a homework answer or to wire the same numbers into a spreadsheet that uses the computational formula. The preferred fields are x and y, each an array of finite numbers of equal length, but aliases a and values_x and series_x for the first series and b and values_y and series_y for the second are accepted so spreadsheets, query strings, and typed forms can reuse the same contract. A single comma-separated or whitespace-separated string of numbers is also accepted for each field when a form posts plain text instead of JSON arrays. The engine enforces a hard maximum of ten thousand pairs and a per-value magnitude ceiling so memory and latency stay inside a predictable budget on the free browser path and on the edge Worker. Pair the free browser run on this page with the priced API when you need the identical bivariate result inside an automated pipeline without re-implementing Pearson’s formula yourself.
Where Pearson correlation fits in study, science, and product work
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result.
Integration use cases
Deterministic CI fixtures
Generate reproducible r values for unit tests and data-quality gates without hand-maintaining bivariate tables.
Technical questions
Why must x and y have the same length?
Pearson r is defined on paired observations. Unequal lengths would invent or drop pairs, so the tool rejects them with invalid_input.