Skip to content

Pearson Correlation Calculator

Calculate pearson correlation with instant, accurate results and clear step-by-step output.

By CalcGenius Editorial TeamLast reviewed August 28, 20253 min read
Pearson Correlation Calculator — r, R², t-test, p-value

X has 8 values, Y has 8 values, using first 8 paired.

📊
Enter your values and click Calculate

About

The Pearson product-moment correlation coefficient (r) measures the strength and direction of a linear relationship between two continuous variables. It ranges from −1 (perfect negative linear) through 0 (no linear relationship) to +1 (perfect positive linear). Pearson r is the most widely used correlation coefficient and the foundation of linear regression.

Mathematically, r is the covariance of X and Y divided by the product of their standard deviations: r = cov(X,Y) / (σ_X × σ_Y). Equivalently, r = Σ((x−x̄)(y−ȳ)) / √(Σ(x−x̄)² × Σ(y−ȳ)²). The numerator captures how X and Y vary together; the denominator normalizes so the result is dimensionless and bounded in [−1, +1]. The sign of r matches the sign of the covariance, indicating direction.

R² — the coefficient of determination — is the square of r. It represents the proportion of variance in Y explained by X (or vice versa) in a linear model. An r of 0.8 gives R² of 0.64, meaning 64% of the variance in Y is explained by X. R² is the more intuitive effect-size measure for prediction; r preserves the direction of the relationship (sign of the slope).

The standard null-hypothesis test sets H₀: ρ = 0 (true population correlation is zero). The test statistic t = r × √((n−2)/(1−r²)) follows a Student's t distribution with n−2 degrees of freedom under H₀. The two-tailed p-value gives the probability of observing |r| this large or larger if the null were true. Small p suggests rejecting H₀ — but with large n, even trivial r values become statistically significant, so always report effect size alongside p-value.

Pearson r assumes linearity, continuous variables, no significant outliers, roughly normal distributions of both variables (for inference), and homoscedastic residuals. Violate any and consider alternatives: Spearman ρ for ordinal or non-monotonic data, Kendall τ for small samples with ties, point-biserial for binary vs continuous, or regression for predictor-control scenarios. Always plot a scatter plot first — a U-shaped relationship can have r near zero despite a strong deterministic link. Correlation does not imply causation; the observed association may be driven by a third confounder, reverse causality, or coincidence.

How to Use

  1. 1
    Enter your X values, comma separated
    Type the X variable values, separated by commas or whitespace. Example: 1, 2, 3, 4, 5, 6, 7, 8. The parser tolerates newlines and trailing commas.
  2. 2
    Enter your Y values, comma separated
    Type the Y variable values for the same observations, in the same order as X. X and Y must have the same number of values — paired observations are required.
  3. 3
    Read the Pearson r and R²
    The hero shows r and its direction (positive / negative / none). Below it: R² (proportion of variance explained), standard error of estimate, and the regression slope.
  4. 4
    Check the t-statistic and p-value for significance
    The t-statistic tests the null hypothesis that the true correlation is zero. The two-tailed p-value is computed exactly using the Student's t CDF with n−2 degrees of freedom.
  5. 5
    Interpret with the comparison table
    The table shows common effect-size conventions (small, medium, large) and the minimum r needed for significance at α = 0.05 by sample size — useful for sanity-checking whether your result is meaningful.

Formula

Pearson r (sample correlation):

r = Σ((x − x̄)(y − ȳ)) / √(Σ(x − x̄)² × Σ(y − ȳ)²)

Equivalent form:

r = cov(X, Y) / (σ_X × σ_Y)

Covariance:

cov(X, Y) = Σ((x − x̄)(y − ȳ)) / (n − 1)

Coefficient of determination:

R² = r²

Null hypothesis test:

H₀: ρ = 0 vs H₁: ρ ≠ 0

t = r × √((n − 2) / (1 − r²)) with df = n − 2

Two-tailed p-value (exact, via regularized incomplete beta function):

p = 2 × (1 − F_t(|t|, df)) = I(df/(df+t²), df/2, 0.5)

Least-squares regression line:

β₁ = cov(X, Y) / σ_X² (slope)

β₀ = ȳ − β₁ × x̄ (intercept)

Standard error of estimate:

SE = √(Σ(yᵢ − ŷᵢ)² / (n − 2))

Where:

  • x̄, ȳ = sample means of X and Y
  • σ_X, σ_Y = sample standard deviations
  • n = number of paired observations (n ≥ 3)
  • F_t = CDF of Student's t with df degrees of freedom
  • I = regularized incomplete beta function

Worked Example

For X = (1, 2, 3, 4, 5, 6, 7, 8) and Y = (2.1, 3.9, 6.2, 7.8, 10.1, 12.0, 14.1, 16.2):

  • n = 8, x̄ = 4.5, ȳ = 9.05
  • cov(X, Y) ≈ 6.30
  • σ_X² ≈ 5.25, σ_Y² ≈ 25.24, σ_X × σ_Y ≈ 11.50
  • r ≈ 6.30 / 11.50 ≈ 0.9978 (very strong positive)
  • R² ≈ 0.9956 — 99.56% of variance in Y explained by X
  • t = 0.9978 × √(6 / (1 − 0.9956)) ≈ 0.9978 × √1363.6 ≈ 36.86
  • df = 6, p-value ≈ 0.0000 (highly significant)
  • Slope β₁ ≈ 6.30 / 5.25 ≈ 2.00 (best-fit line y = β₀ + 2.00x)
  • Intercept β₀ ≈ 9.05 − 2.00 × 4.5 ≈ 0.05
  • SE of estimate ≈ 0.18 — residuals are very small

Tips

  • Always plot a scatter plot before computing Pearson r — a curvilinear relationship (U-shape) can have r near zero despite a strong deterministic link.
  • Report r, R², p-value, and n together. A p < 0.05 with r = 0.10 is statistically significant but practically meaningless for most purposes.
  • Check for outliers — a single extreme point can inflate or deflate r dramatically. Try computing r with and without outliers to assess robustness.
  • Use Spearman ρ instead of Pearson r if the relationship is monotonic but not linear, or if either variable is ordinal or has heavy outliers.
  • Statistical significance depends heavily on sample size. With n = 1000, r = 0.10 is significant; with n = 10, you need r ≥ 0.632 for significance at α = 0.05.
  • Correlation does not imply causation. A third variable (confounder) may drive both X and Y. Controlled experiments or causal inference methods are required for causal claims.

Common Mistakes

Common mistakes
  • Reporting p-value without effect size — with large n, even trivial r is significant. Always report r and R² with p.
  • Assuming linearity from r alone — a U-shaped or exponential relationship can have r near zero.
  • Ignoring outliers — a single extreme point can shift r dramatically. Use Spearman ρ or robust regression.
  • Interpreting correlation as causation — only controlled experiments or causal inference methods establish causation.
  • Computing r on non-paired data — X and Y must be paired observations of the same n units. Mixing unpaired X and Y gives meaningless r.
  • Using Pearson for ordinal or rank data — use Spearman ρ or Kendall τ instead.

Frequently Asked Questions

What does Pearson correlation measure?
Pearson r measures the strength and direction of a linear relationship between two continuous variables, ranging from −1 (perfect negative linear) through 0 (no linear relationship) to +1 (perfect positive linear). It is the most widely used correlation coefficient and is computed as the covariance of X and Y divided by the product of their standard deviations. Pearson r only captures linear association — a curvilinear relationship can have r near zero despite a strong deterministic link.
What is the difference between r and R²?
r is the correlation coefficient (range −1 to +1). R² (coefficient of determination) is r squared (range 0 to 1). R² represents the proportion of variance in Y that is explained by X in a linear model — if r = 0.8, then R² = 0.64, meaning 64% of the variance in Y is explained by X. R² is the more intuitive effect-size measure for prediction, while r preserves direction.
How is the p-value computed?
Under the null hypothesis (true correlation is zero), the test statistic t = r × √((n−2)/(1−r²)) follows a Student's t distribution with n−2 degrees of freedom. The two-tailed p-value is the probability of observing |t| this large or larger under that distribution. The calculator computes this exactly using the regularized incomplete beta function for the Student's t CDF.
What does a significant p-value mean?
A small p-value (typically < 0.05) means the observed correlation is unlikely under the null hypothesis of no linear relationship. It does NOT mean the correlation is strong — with large n, even trivial r values become statistically significant. Always report effect size (r and R²) alongside p-value. A p < 0.05 with r = 0.1 is statistically significant but practically meaningless for most purposes.
When is Pearson correlation inappropriate?
Pearson assumes (1) linearity, (2) continuous variables, (3) no significant outliers, (4) roughly normal distributions of both variables (for inference), and (5) homoscedastic residuals. Violate any and consider alternatives: Spearman ρ for ordinal or non-monotonic data, Kendall τ for small samples with ties, point-biserial for binary vs continuous, or regression for predictor-control scenarios.
How many data points do I need?
Theoretically 3, but practically you want at least 10–20 for stable estimates and meaningful inference. With n = 3, r is essentially a function of two points and tells you nothing. With n = 30+, the central limit theorem makes the t-test p-value reliable even for non-normal data. Small samples require larger |r| for significance — see the comparison table for thresholds.

Covariance and correlation

Covariance measures how two variables vary together: cov(X,Y) = Σ((x−x̄)(y−ȳ)) / (n−1). It is unit-dependent and hard to interpret. Pearson correlation normalizes covariance by the product of standard deviations: r = cov(X,Y) / (σ_X × σ_Y). This makes r dimensionless and bounded in [−1, +1]. A perfect positive linear relationship gives r = 1; perfect negative gives r = −1.

Coefficient of determination R²

R² is the square of Pearson r. It represents the proportion of variance in Y explained by X (or vice versa) in a linear model — the "coefficient of determination." An r of 0.8 gives R² of 0.64, meaning 64% of the variance is shared. R² is the more intuitive effect-size measure for prediction, while r preserves the direction of the relationship (sign of the slope).

Null hypothesis test

The standard test of Pearson correlation sets H₀: ρ = 0 (true population correlation is zero). The test statistic t = r × √((n−2)/(1−r²)) follows a Student's t distribution with n−2 degrees of freedom under H₀. The two-tailed p-value gives the probability of observing |r| this large or larger if the null were true. Small p suggests rejecting H₀.

Causation vs correlation

"Correlation does not imply causation" — the most cited rule in introductory statistics. A non-zero Pearson r means two variables are linearly associated, but the cause could be a third confounder, reverse causality, or pure coincidence. Establishing causation requires controlled experimentation or causal inference methods (instrumental variables, regression discontinuity, propensity matching). Always report correlation alongside effect size and avoid causal language for observational data.

Cohen's effect-size conventions and minimum r for statistical significance at α = 0.05.
Effect size|r| conventionR²Notes
Small (Cohen)|r| ≈ 0.100.01Detectable in n ≥ 100 samples
Medium (Cohen)|r| ≈ 0.300.09Detectable in n ≥ 30–50 samples
Large (Cohen)|r| ≈ 0.500.25Detectable in n ≥ 15–20 samples
Very large|r| ≈ 0.700.49Half of variance explained
Near-perfect|r| ≈ 0.900.81Strong linear association
Min |r| for p < 0.05n=10: 0.632—Critical r for significance at α=0.05
How the p-value is computed exactly
Under H₀: ρ = 0, the statistic t = r × √((n−2)/(1−r²)) follows a Student's t distribution with n − 2 degrees of freedom. The two-tailed p-value is p = 2 × (1 − F_t(|t|, df)). This calculator computes F_t (the Student's t CDF) exactly using the regularized incomplete beta function I_x(df/2, 1/2) with x = df / (df + t²), via Lanczos log-gamma and continued-fraction evaluation — accurate to about 12 significant digits.
Plot before you compute
Always plot a scatter plot of X and Y before computing r. A perfect curvilinear relationship (e.g., y = x² for symmetric x) has r ≈ 0 despite being 100% deterministic. The Anscombe's quartet demonstrates four datasets with identical Pearson r but wildly different visual patterns. A scatter plot reveals the shape, the outliers, and the homoscedasticity that r alone cannot.

Authoritative References

Try our other free calculators

CalcGenius has 1,200+ free, ad-free, browser-based calculators for finance, health, math, science, and everyday life. No sign-up required.

Pearson Correlation Calculator — Mean, Variance & Confidence