Correlation vs Causation and Sample Size Sandbox

Two quick demos that show why small samples mislead. Free, no sign-up, runs in your browser. Level: Foundation.

Two quick demos that show why small samples mislead: a fair coin can look biased after a few flips, and two sets of numbers with nothing in common can look strongly linked when there are only a few of them.

Level: Foundation · Prerequisite: none

How it works

  1. Pick a demo. Start with the coin flips (Demo A), then try the random scatter plot (Demo B).
  2. Choose a sample size. For coins, pick 10, 50, 100 or 1000 flips. For the scatter plot, pick n of 5, 10, 20, 50 or 100.
  3. Press Run (coins) or Generate new random data (scatter plot). Each run makes fresh random data.
  4. Read what the numbers mean. Each demo explains its result in plain language below the controls.
  5. Run it again. Random data changes every time, which is part of the lesson. Try small numbers first, then large ones, so you can compare.
  6. Use Generate 10 samples in Demo B to see ten fresh pairs of unrelated numbers at once. The largest correlation by size is highlighted.

Demo A: Coin-flip streaks

A fair coin lands on heads about half the time in the long run. But after only a few flips, the share of heads can sit far from 50%. Choose how many flips to run, then press Run.

Number of flips

Press Run to flip the coin.

The flips are simulated random data made by this page, not results from a real experiment. Every run gives a different set of flips.

Demo B: Spurious correlation

These two sets of numbers are generated independently, so there is no real link between them at all. Yet with only a few points, they can still look strongly linked just by chance. Choose a sample size, then generate some random data.

Sample size (n)

Press "Generate new random data" to see a correlation.

Method: each set is drawn independently from a standard normal distribution using the Box-Muller method, so the two sets have no real link. The Pearson correlation r is calculated from the numbers shown, using the standard formula (covariance divided by the product of the two standard deviations). This is simulated random data, not real study data.

See the numbers used
No data generated yet.
Correlation does not prove causation, and small samples mislead. A strong link between two things can appear by chance alone when the sample is small, and even a real link does not show that one thing causes the other. Before trusting a headline, check the sample size and ask what else could explain the link.

A fair coin can look biased after a few flips, and two unrelated sets of numbers can look linked when there are only a few of them. Demo A flips a coin up to 1000 times. Demo B draws two independent sets of numbers and reports their Pearson correlation r. A strong link in a small sample can be chance.

Formulas and method

Pearson correlation r measures how closely two sets of numbers move together in a straight line:

r = sum of (x minus x-bar)(y minus y-bar) divided by the square root of [sum of (x minus x-bar) squared times sum of (y minus y-bar) squared]

r runs from -1 to +1. Near +1 means the numbers rise together, near -1 means one falls as the other rises, near 0 means no straight-line link. Demo B draws each set independently from a standard normal distribution using the Box-Muller method, so the two sets have no real link at all. The r shown is calculated from the numbers on screen with the standard formula above.

Worked example 1: coin flips

A fair coin lands on heads about half the time in the long run. But 9 or 10 heads in 10 flips is not that rare. The chance is (10 + 1) / 1024 = 11 / 1024, about 1.1 percent, so roughly 1 run in 90. Eight or more heads in 10 flips happens about 5.5 percent of the time, roughly 1 run in 18. A short run that looks biased is exactly what chance produces. Run 1000 flips instead and the share of heads sits close to 50 percent.

Worked example 2: a chance correlation

Take five pairs of numbers with no link between them: x = 6, 2, 8, 3, 9 and y = 4, 7, 5, 9, 3. Their Pearson correlation is r = -0.84, which looks like a strong link. It is not. The numbers were picked with no connection between the two lists, and with only five points a large r appears often: in a simulation of 20,000 repeats, about 1 run in 10 at n = 5 gave |r| above 0.8, while at n = 50 it almost never happened. Small samples mislead; large samples do not fix a missing causal link, they only show the link more clearly.

Common mistakes

Frequently asked questions

What is the difference between correlation and causation?

Correlation means two things move together. Causation means changing one thing changes the other. A correlation can come from chance, from a third factor, or from reverse causation, so it never proves causation on its own.

Why do small samples give misleading correlations?

With few points, chance has more room to shape the result. At n = 5, unrelated numbers give |r| above 0.8 in about 1 run in 10. At n = 50, that almost never happens.

Can a fair coin really give 9 heads in 10 flips?

Yes. It happens about 1.1 percent of the time, roughly 1 run in 90. A short streak that looks biased is normal chance, not proof the coin is rigged.

Does a correlation of 0 mean there is no relationship?

No. It means there is no straight-line relationship. Two things can still be linked in a curve, or in groups, while r sits near 0.

What is the Box-Muller method?

It is a standard way to turn uniform random numbers into numbers from a normal distribution. Demo B uses it to draw two independent sets of numbers, so any link you see between them is chance alone.

Related tools and guides

Sources

Last reviewed: 17 November 2026