Bayes teorem

Bayes teorem

Bayes teorem

This is bluntly copied from https://www.freecodecamp.org/news/bayes-rule-explained/ to keep the information locally

The equation itself is not too complex:

Probability of event A given event B equals Prior probability of event A times Probability of event B given A, divide by marginal probability of event B
The equation: Posterior = Prior x (Likelihood over Marginal probability)

There are four parts:

  • Posterior probability (updated probability after the evidence is considered)
  • Prior probability (the probability before the evidence is considered)
  • Likelihood (probability of the evidence, given the belief is true)
  • Marginal probability (probability of the evidence, under any circumstance)

Worked example of Bayes' Rule

Here's a simple worked example.

Your neighbour is watching their favourite football (or soccer) team. You hear them cheering, and want to estimate the probability their team has scored.

Step 1 – write down the posterior probability of a goal, given cheering

Step 2 – estimate the prior probability of a goal as 2%

Step 3 – estimate the likelihood probability of cheering, given there's a goal as 90% (perhaps your neighbour won't celebrate if their team is losing badly)

Step 4 – estimate the marginal probability of cheering – this could be because:

  • a goal has been scored (2% of the time, times 90% probability)
  • or any other reason, such as the other team missing a penalty or having a player sent off (98% of the time, times perhaps 1% probability)

Now, piece everything together:

Probability of goal, given cheering equals prior probability of goal times probability of cheering given goal, divided by probability of cheering given goal plus probability of cheering given no goal. Equals 0.02 times 0.9 over 0.02 times 0.9 plus 0.98 times 0.01 = 64.7 percent