PhysSandbox
Classical MechanicsWaves & SoundElectricity & MagnetismOptics & LightGravity & OrbitsLabsLessons
🌙Astronomy & The Sky🌡️Thermodynamics🌍Biophysics, Fluids & Geoscience📐Math Visualization🔧Engineering🧪Chemistry📊Statistics & Probability
ENRUESPTFRDE

Related simulators

Continue with similar topics in this category — or all 10 in Statistics & Probability.

View category →
NewKids

Normal Distribution & z-Scores

Launch Simulator

Bell curve with μ and σ; shaded tails, the 68–95–99.7 rule, and a built-in z-score converter x → z = (x − μ)/σ.

NewFeaturedKids

Galton Board (Bean Machine)

Launch Simulator

Balls bounce left/right through rows of pegs; the bins fill a binomial that turns into a bell curve. Few rows vs many rows.

NewKids

Binomial Distribution

Launch Simulator

P(K = k) bars for n trials with success p; mean np, variance np(1−p); coin and rare-event presets; normal overlay at large n.

NewFeaturedKids

Central Limit Theorem

Launch Simulator

Pick a parent (uniform, exponential, binomial, die), draw samples of size n = 1, 5, 30; the histogram of means turns normal and its spread shrinks as σ/√n.

NewKids

Law of Large Numbers

Launch Simulator

Coin or die: running mean x̄ₙ for several runs converges to μ; the ±σ/√n envelope shows how slowly.

NewSchool

Type I & II Errors and Statistical Power

Launch Simulator

Two normal curves (H₀ and H₁), a decision threshold; α, β and power 1−β as shaded areas; effect size, σ and n sliders.

PhysSandbox

Interactive physics, chemistry, and engineering simulators for students, teachers, and curious minds.

Physics

  • Classical Mechanics
  • Waves & Sound
  • Electricity & Magnetism

Science

  • Optics & Light
  • Gravity & Orbits
  • Astronomy & The Sky

More

  • Thermodynamics
  • Biophysics, Fluids & Geoscience
  • Math Visualization
  • Engineering
  • Chemistry
  • Statistics & Probability

© 2026 PhysSandbox. Free interactive science simulators.

PrivacyTermsContact
Home/Statistics & Probability/Pearson Correlation

Pearson Correlation

Scatter cloud with adjustable r, covariance ellipse, and a parabola preset where r ≈ 0 despite a perfect relationship.

Scatter cloud

0.7
100

Presets (override the generator)

Points are drawn from a bivariate normal distribution with unit variances: x ~ N(0,1), y = ρx + √(1−ρ²)·ε with ε ~ N(0,1), so the population correlation is exactly ρ and the sample r scatters around it. Presets replace this generator; moving the ρ slider returns to it. r measures linear association only; a parabola can give r ≈ 0, one outlier can pull r far from the rest of the data, and correlation never shows causation. Drag any point or click empty space to add one — r updates live.

Shortcuts

  • •Space / Enter — new random cloud (same settings)
  • •R — reset to defaults
  • •Drag a point · click empty space to add a point

Measured values

Points N0
Pearson r—
r²—
Covariance s_xy—
Std. deviation s_x—
Std. deviation s_y—
Points in ++ / −− quadrants0
Points in +− / −+ quadrants0

About this model

The simulator draws a cloud of N points and reports the sample Pearson correlation coefficient. By default the points come from a bivariate normal distribution with unit variances: x ~ N(0, 1), ε ~ N(0, 1) and y = ρx + √(1 − ρ²)·ε, the one-step Cholesky construction, so that the population correlation of x and y is exactly the slider value ρ. The sample value r is computed from the standard formula with two-pass means: first x̄ = Σxᵢ/N and ȳ = Σyᵢ/N, then r = Σ(xᵢ − x̄)(yᵢ − ȳ) / √(Σ(xᵢ − x̄)² · Σ(yᵢ − ȳ)²). The readouts also give the sample covariance s_xy = Σ(xᵢ − x̄)(yᵢ − ȳ)/(N − 1), the sample standard deviations s_x and s_y with the same N − 1 denominator, r² and, when the line is switched on, the least-squares slope b = s_xy / s_x² = r·s_y/s_x. The dashed mean lines split the plane into four quadrants; a point in the ++ or −− quadrant contributes a positive term (xᵢ − x̄)(yᵢ − ȳ) to the covariance and is drawn cyan, a point in the +− or −+ quadrant contributes a negative term and is drawn pink, and the counts of both groups are shown. The green ellipse is the 1σ contour of the fitted bivariate normal: its axes are the square roots of the eigenvalues of the covariance matrix [[s_x², s_xy], [s_xy, s_y²]] and its tilt is θ = ½·atan2(2s_xy, s_x² − s_y²). Presets replace the generator with cases that expose the limits of r: a parabola y = x² on x ∈ [−1, 1] with small noise, where y is a deterministic function of x yet r ≈ 0; an uncorrelated cloud plus a single far point at (√1.5N, √1.5N), which alone lifts r to about 0.6; and two tight, internally uncorrelated clusters whose separation produces r ≈ 0.96. Points can be dragged and added by clicking, with every statistic recomputed exactly on each change. Simplifications: no inferential statistics are shown (no p-value or confidence interval for r, no Fisher z-transform), the regression line is only an overlay — least-squares fitting itself is treated in math/least-squares and goodness-of-fit in math/linear-regression-metrics — and the plot auto-scales to the data, so the ellipse can look circular or thin depending on axis ranges. Companion simulators: statistics/normal-distribution for the marginal distribution of x and y, statistics/central-limit-theorem for why averages of many points behave normally.

Who it's for: Upper secondary (grades 10–12) and first-year introductory statistics; also suitable for data-science foundations courses.

Key terms

  • Pearson correlation coefficient r
  • covariance
  • standard deviation
  • linear association
  • coefficient of determination r²
  • outlier
  • bivariate normal distribution
  • correlation vs causation

How it works

The Pearson correlation coefficient r measures how tightly a cloud of points follows a straight line: r = Σ(x − x̄)(y − ȳ) / √(Σ(x − x̄)² · Σ(y − ȳ)²), always between −1 and 1. The dashed lines mark the means x̄ and ȳ; a point in the ++ or −− quadrant (cyan) contributes a positive product to the covariance, a point in the +− or −+ quadrant (pink) a negative one, and r is simply the covariance divided by the two standard deviations. The green 1σ ellipse is tilted by the covariance and becomes a thin diagonal as |r| → 1. r describes linear association only: the Parabola preset is a perfect y = x² relationship with r ≈ 0, a single far outlier can push r from 0 to 0.6, and two separated clusters give a high r with no relationship inside either cluster. A high r never by itself shows that x causes y.

Key equations

r = Σ(xᵢ − x̄)(yᵢ − ȳ) / √( Σ(xᵢ − x̄)² · Σ(yᵢ − ȳ)² ) = s_xy / (s_x s_y)
s_xy = Σ(xᵢ − x̄)(yᵢ − ȳ) / (N − 1), s_x² = Σ(xᵢ − x̄)² / (N − 1)
generator: x ~ N(0,1), ε ~ N(0,1), y = ρx + √(1 − ρ²) ε ⇒ corr(x, y) = ρ
least-squares slope b = s_xy / s_x² = r · s_y / s_x
1σ ellipse: axes √λ₁, √λ₂ of the covariance matrix [[s_x², s_xy], [s_xy, s_y²]], tilt θ = ½·atan2(2 s_xy, s_x² − s_y²)

Frequently asked questions

Why is r almost zero for the parabola even though y is completely determined by x?
Pearson's r measures only linear association: how well a straight line describes the cloud. For y = x² on a symmetric interval, points with negative x sit in the −+ quadrant and points with positive x sit in the ++ quadrant, so the positive and negative products (x − x̄)(y − ȳ) cancel and the covariance is close to zero. The relationship is perfect but not linear, so r cannot see it. Looking at the scatter plot before trusting r is essential; a correlation ratio or a rank-based measure would detect this dependence, Pearson's r does not.
How can one single point change r from 0 to 0.6?
Every term in the covariance is a product of two deviations from the means, so a point far from both means contributes a huge product while ordinary points contribute small ones. With an uncorrelated cloud of variance about 1 and one point at (a, a), the correlation is roughly a² / (N + a²); for a² = 1.5 N that is about 0.6 whatever N is. The same point also inflates s_x and s_y, but the covariance grows faster. This is why r is called non-robust: a measurement error or a special case can dominate the number, and such points should be checked before interpreting r.
What is the difference between covariance and correlation?
Covariance s_xy = Σ(x − x̄)(y − ȳ)/(N − 1) carries the units of x times the units of y, so its size depends on the measurement scale: measuring height in centimetres instead of metres multiplies it by 100. Dividing by the two standard deviations removes the units and gives r = s_xy / (s_x s_y), which is always between −1 and +1 and is unchanged by any linear rescaling of x or y. Covariance tells you the sign and the raw strength of the joint variation; correlation puts it on a common scale that can be compared across data sets.
If two quantities have r = 0.9, does one cause the other?
No. Correlation describes how two sets of numbers vary together, not why. A high r is consistent with x causing y, y causing x, both being driven by a third variable (ice-cream sales and drownings both rise in summer), or a selection effect in how the data were collected. The two-clusters preset shows another trap: r ≈ 0.96 arises only because two groups differ in both variables, while within each group there is no relation at all. Establishing causation requires a controlled experiment or a careful causal argument, not a correlation coefficient.