AP® Computer Science Principles · Big Idea 2 · Topic 2.3

Correlation and Causation

Correlation means two variables rise and fall together in the data. Causation means one actually makes the other happen, and a strong correlation alone never proves that.

A correlation is just a pattern: when one number goes up, another tends to go up (or down) too. Ice cream sales and drowning deaths both climb every summer, so they are correlated. But nobody thinks eating ice cream makes you drown. The real driver is a hidden third variable, here, hot weather, that pushes both numbers up at the same time. More people swim when it is hot, and more people buy ice cream when it is hot. The two effects move together only because they share a cause, not because they touch each other.

This matters for data work because it is tempting to read a clean scatterplot or a huge data set and assume the strongest story is the true one. A tight correlation, even across millions of data points, only tells you the two variables move together. It says nothing about why. Sample size can make a correlation look statistically convincing without making it causally true; two million users wearing fast running shoes and running fast marathons could just as easily share a cause like training experience, since serious runners buy serious gear and also run more.

To defend an actual cause-and-effect claim, you need more than a pattern in observed data: a controlled experiment that changes one variable while holding others fixed, a mechanism that explains how one thing could physically produce the other, and ideally the pattern showing up again in independent data sets. This idea connects to how data gets collected and visualized earlier in the unit, reminding you that a well-made chart can be fully accurate and still support a false conclusion if you stop at the correlation.

Key terms

Correlation
A pattern where two variables tend to rise or fall together in the data.
Causation
A relationship where a change in one variable actually produces a change in another.
Confounding variable
A hidden third factor that influences both measured variables, creating a correlation without direct cause.
Controlled experiment
A test that changes one variable while holding others constant to isolate its effect.

Watch it explained

  1. How it worksHow does a hidden third variable make two unrelated things look tightly linked?
  2. Worked exampleShow me a scatterplot with a strong correlation whose causal story is still completely wrong.
  3. Common mistakeWhy doesn't a tight correlation in a huge data set prove that one thing caused the other?
  4. Going furtherWhat extra evidence turns a correlation into a claim about cause you could defend?

Check yourself

Your turn1 of 2
In a data set of 93 summer days, ice cream sales and drownings both rise together on 18 of those days because heat drives both. On how many of the n days do the two NOT move together this way?

End of topic.