Statistics · Playground · 5 min

Correlation playground

Move the dots, change the pattern, and watch Pearson’s correlation coefficient respond.

05/ 08
Make it your own

Change a value. See what changes.

What happensLive calculation

The idea to keep

Correlation measures a linear pattern. A curved relationship can be strong even when r is near zero.

01 / The explanation

What is going on?

Pearson’s r measures the direction and strength of a linear association. It runs from −1 to +1. Positive values describe points tending upward together; negative values describe one variable tending down as the other rises. Values near zero indicate little linear association, not necessarily no relationship.

r = Σ(xᵢ − x̄)(yᵢ − ȳ) / √[Σ(xᵢ − x̄)² Σ(yᵢ − ȳ)²]
02 / Step by step

Work through it

  1. Begin with a pattern or enter your own x,y pairs.
  2. Drag a point to change the data. Keyboard users can focus a point and move it with the arrow keys.
  3. Compare the scatterplot with the value of r. Try adding an outlying point or selecting the curved example.
03 / A worked example

Put numbers to the idea

The points (1,2), (2,4), and (3,6) lie on a straight rising line, so r = 1. For (1,6), (2,4), and (3,2), r = −1. A symmetric U-shaped pattern can have r = 0 even though y clearly depends on x.

04 / Common questions

A little more clarity

Does correlation imply causation?

No. Two variables can move together because of a third factor, reverse causation, selection effects, or chance. Establishing causation requires additional evidence and study design.

Can one outlier change the result?

Yes. Because the calculation uses products of deviations, a distant point can have a large effect. Always inspect the plot as well as the coefficient.

Why does a flat dataset give an undefined result?

If all x values or all y values are identical, one of the squared-deviation sums is zero. The correlation formula then divides by zero.