Correlation Calculator

Compute Pearson and Spearman correlation coefficients between two paired datasets. Includes a scatter chart with regression line.

View guide

Guide

What does this tool do

The Correlation Calculator computes the relationship between two paired datasets (X and Y). Enter two lists of numbers with the same length, and it calculates Pearson correlation (linear relationship), Spearman rank correlation (monotonic relationship), and sample covariance. A scatter chart displays your data points plus a linear regression (correlation) line for visual interpretation. Ideal for homework, research, and data analysis when exploring whether two variables are related.

How to use it

  1. Enter X values — Paste or type the first variable (e.g. hours studied). Comma or space separated.
  2. Enter Y values — Paste or type the second variable (e.g. test scores). Must have the same number of values as X.
  3. Calculate — Click the button to compute Pearson r, Spearman ρ, and covariance.
  4. View the chart — The scatter plot shows data points and the regression line.
  5. Try presets — Use Quick Presets for perfect positive, perfect negative, weak positive, or no correlation examples.

How it works

The tool parses both input strings into number arrays (comma or whitespace separated), validates they have the same length (minimum 2, maximum 10,000 pairs), and delegates to the simple-statistics library for:

  • Pearson r — Sample correlation coefficient: covariance(X,Y) / (σ_X × σ_Y). Measures linear association.
  • Spearman ρ — Rank correlation: Pearson applied to rank-transformed data. Measures monotonic association.
  • Covariance — Sample covariance of the two variables.

The scatter chart uses Recharts with lineType="fitting" to draw the linear regression line automatically from your data.

All computation runs entirely in your browser. No data is sent to any server.

Use cases & examples

  • Homework — Compute correlation for paired data in statistics or psychology.
  • Research — Explore relationships between variables (e.g. temperature vs. ice cream sales).
  • Quality — Check if two measurements or processes are related.
  • Finance — Assess correlation between returns of two assets.

Example

Hours studied (X): 2, 4, 6, 8, 10
Test score (Y): 65, 72, 78, 85, 92

  • Pearson r ≈ 0.99 (strong positive)
  • Spearman ρ ≈ 1 (perfect rank correlation)
  • The scatter chart shows points closely following an upward trend line.

Limitations & known constraints

  • Paired data only — X and Y must have exactly the same length.
  • Minimum 2 pairs — At least two (X, Y) pairs are required.
  • Maximum 10,000 pairs — Very long lists may slow the UI.
  • Linear regression — The fitted line assumes a linear relationship; it does not model curves.
  • No significance testing — The tool does not compute p-values; use dedicated software for hypothesis testing.

FAQ

What is Pearson correlation?
Pearson r measures the linear relationship between two variables. It ranges from -1 (perfect negative) to +1 (perfect positive). Zero means no linear correlation.
What is Spearman correlation?
Spearman ρ measures the monotonic relationship (rank-based). It is better than Pearson when data is not normally distributed or has outliers.
How do I interpret the scatter chart?
Points show your (X, Y) pairs. The line is the linear regression (best-fit) line. A steep positive slope indicates positive correlation; steep negative slope indicates negative correlation.

All calculations and conversions run entirely in your browser. No data is sent to any server, so your input never leaves your device.