Statistics and data

Correlation Calculator

Find Pearson's r for two sets of paired observations, with squared correlation, pair count, and the mean of each variable.

Calculate Pearson correlation for paired values

Enter one number per line in each list. X row 1 pairs with Y row 1, and so on. Use commas only for grouped thousands: 1,000 means one thousand. Surrounding blank lines are ignored; blank rows inside a list are rejected.

2–100 pairs; up to 15 integer digits and 10 decimal places per value.

Pearson correlation (r)

Enter your paired values, then select Calculate.

Enter adds a new line. Press Ctrl+Enter or Command+Enter to calculate, or select Calculate. Calculations run in your browser; successful results appear in this tab's Recent calculations.

Formula and worked examples

Pearson's correlation divides the sum of products of deviations from each mean by the square root of the two sums of squared deviations:

r = Σ[(x − x̄)(y − ȳ)] ÷ √[Σ(x − x̄)² × Σ(y − ȳ)²]

The result lies between −1 and 1. A positive sign means the linear association slopes upward; a negative sign means it slopes downward. Exactly −1 or 1 describes an exact straight-line relationship in these data, while exactly 0 means no linear correlation. A curved relationship may still exist when r is zero.

Worked example

Five paired observations

X: 1, 2, 3, 4, 5
Y: 2, 4, 5, 4, 5

The means are 3 and 4. The centered cross-products sum to 6; the squared deviations sum to 10 for X and 6 for Y.

r = 6 ÷ √60 ≈ 0.774597
r² = 0.6

Opposite directions

An exact negative line

X: 1, 2, 3
Y: 6, 4, 2

r = −1
r² = 1

Every pair lies on y = 8 − 2x. Squaring r removes its direction, so read r² together with r.

A curved pattern

Zero linear correlation

X: −1, 0, 1
Y: 1, 0, 1

r = 0
r² = 0

These points follow y = x². Zero Pearson correlation does not mean the variables have no relationship.

Interpreting the results

Squared correlation, r², ranges from 0 to 1. For simple least-squares linear regression with an intercept fitted to these same pairs, r² is the coefficient of determination: the fraction of observed Y variation accounted for by the fitted line. In the example, r² = 0.6 corresponds to 60%. This interpretation does not establish a causal effect or guarantee accurate predictions on new observations.

With only two pairs and variation in both variables, |r| is always exactly 1. More observations, their collection method, and their pattern matter when assessing a relationship. This calculator reports descriptive statistics and does not calculate p-values, confidence intervals, or statistical significance.

Exact inputs and display rounding

Decimal inputs and centered products are kept exact, so a small difference between large numbers is preserved. The square root for r is rounded using exact integer comparisons. r² is calculated from the original data, rather than by squaring the rounded r.

Choose 0, 2, 4, 6, or 10 decimal places; the default is 6. Exact halfway values round away from zero. The ≈ symbol means the displayed number differs from the exact value. A note identifies nonzero correlations that round to zero and imperfect correlations that round to −1 or 1. Changing precision updates the current result without adding another history entry.

References: NIST — Correlation gives Pearson's formula and the requirement for matched lists. Penn State — Simple Linear Regression explains correlation and the coefficient of determination.

Common questions

Can I paste values from a spreadsheet?

Yes. Paste one numeric column into X and its matching column into Y. Use one number per line and remove headers and units. Both lists must have the same count. Blank rows inside either list produce an error; surrounding blank lines are ignored.

What do commas mean?

Commas are thousands separators, not value separators. A line containing 1,000 is one value equal to one thousand. Use a new line between observations and a period for decimals. A comma-separated list such as 1,2,3 is rejected.

Can X and Y have different units?

Yes. For example, X could be height in centimeters and Y could be mass in kilograms. Keep units consistent within each list. Correlation itself has no unit, while each displayed mean keeps its variable's input unit.

Why is correlation undefined for constant values?

If every value in either list is identical, its squared deviations are all zero. The denominator in Pearson's formula is then zero. This is undefined, not zero correlation.

Is this Spearman rank correlation?

No. This calculator uses the numerical values directly for Pearson's correlation. It does not rank the observations or calculate Spearman's coefficient.

What are the input limits?

Enter 2–100 paired observations, with at most 6,600 characters per list and 64 characters per numeric row. Each value accepts up to 15 integer digits and 10 decimal digits, including an optional keyboard plus or minus sign. Negative values, zero, and repeated observations are allowed. Use a leading zero for decimals such as 0.5. Fractions, expressions, scientific notation, NaN, and Infinity are rejected.