What is Bayes theorem?

A rule for updating the probability of a hypothesis when new evidence arrives, combining prior belief with how likely the evidence is.

Bayes theorem diagram example

Public diagram from the Machinations Community. Open it on its own page

Bayes' theorem tells you how to revise a probability after you observe something new. It says that the updated belief depends on how likely the hypothesis was to begin with and on how strongly the evidence points to it. It matters because people routinely ignore the starting rate and overreact to a single test result.

How it works

In symbols, P(A given B) = P(B given A) x P(A) / P(B). P(A) is the prior, the probability before the evidence. P(B given A) is the likelihood, how often the evidence appears when the hypothesis is true. P(B) is the overall chance of seeing the evidence, whether the hypothesis is true or not.

When the hypothesis is rare, even a fairly accurate test produces many false alarms compared with true detections. The updated probability, called the posterior, can therefore stay low even after a positive result. Each new piece of evidence can be applied in turn, with yesterday's posterior becoming today's prior.

Example

Say a disease affects 1% of a population, and a test catches 90% of true cases but also flags 9% of healthy people. Out of 1,000 people, 10 are sick and 9 of them test positive. Of the 990 healthy people, about 89 also test positive. So 98 people test positive, only 9 of them are sick, and a positive result means roughly a 9% chance of disease, not 90%. Illustrative numbers only.

In a game economy, a designer might ask how likely a player is a future spender given that they bought a starter pack. The answer depends on how few players spend at all, not only on how many starter-pack buyers go on to spend.

How to model it in Machinations

Use a Source for the population, a Gate to split it into true cases and non-cases by the prior probability, and further Gates to apply the test's hit and false-alarm rates. Collect the outcomes in Pools and use a Register to divide true positives by all positives. Change the prior as a Lever and Play to see how the posterior moves.

See Bayes theorem in a system you can Play

Build the rules in a Machinations diagram, change a value and Play it to watch how the system responds.