This theorem provides a way to update our beliefs about an event based on new evidence. It allows us to calculate the probability of an event, given that another event has already occurred.

It’s mathematically represented as:

Where:

  • P(A|B): The posterior probability of event A happening, given that event B has already happened.
  • P(B|A): The likelihood of event B happening given that event A has already happened.
  • P(A): The prior probability of event A happening.
  • P(B): The prior probability of event B happening.

Let’s say we want to know the probability of someone having a disease (A) given that they tested positive for it (B). Bayes' theorem allows us to calculate this probability using the prior probability of having the disease (P(A)), the likelihood of testing positive given that the person has the disease (P(B|A)), and the overall probability of testing positive (P(B)).


Suppose we have the following information:

  • The prevalence of the disease in the population is 1%, so P(A) = 0.01.
  • The test is 95% accurate, meaning if someone has the disease, they will test positive 95% of the time, so P(B|A) = 0.95.
  • The test has a false positive rate of 5%, meaning if someone does not have the disease, they will test positive 5% of the time.
  • The probability of testing positive, P(B), can be calculated using the law of total probability.

First, let’s calculate P(B):

Where:

  • P(¬A): The probability of not having the disease, which is 1 - P(A) = 0.99.
  • P(B|¬A): The probability of testing positive given that the person does not have the disease, which is the false positive rate, 0.05.

Now, substitute the values:

Next, we use Bayes’ theorem to find P(A|B):