Interactive demo · Probability and Statistical Inference · Chapter 1

Bayes' theorem over a partition: base rates

The sample space is split into disjoint classes A1, …, Ak with prior probabilities P(Ai), and we observe an event B whose probability P(B|Ai) depends on the class. In the square, each class is a column whose width is its prior and whose shaded height is P(B|Ai): the shaded area is P(B) (the law of total probability), and the posterior P(Ai|B) is the share of the shaded area that lies in column i (Bayes' theorem). A test that is right 90% of the time therefore says little when the condition it detects is rare: the shaded area is dominated by the wide column of healthy people.

Problem

Base rate P(A₁) (log scale)

Positive tests in a row (independent given the status)

Evidence B

Tracked class (bottom panels)

Simulated individuals N

Try these

Simulation: each individual's class is drawn from the priors, then B occurs with probability P(B|class); the bottom-right panel follows the proportion of the tracked class among those in whom B occurred, which settles on the posterior. Moving the base-rate slider changes the tracked class's prior and rescales the other priors in proportion, keeping their ratios.

In the lecture notes