Explanation of Bayes Theorem and Application Examples

By | Friday, August 2, 2019 1:54

If someone has spots and itching on his skin, how likely is that person to have smallpox? This question may have been in the imagination of doctors in ancient times. At that time the technology was not possible to do blood tests or other biological tests, so medical experts could not conclude whether the symptoms that occur in humans were related to the disease they were suffering.

Let’s just say we are doctors and lived in ancient times and there was an outbreak of smallpox. People in our city must be quarantined so that they are not contagious.

If the possibility of transmission is very low, we need not be afraid, but if the possibility is high, we must immediately urge them not to leave the house first so as not to infect others. This is where a statistical theory formulated by Thomas Bayes is used, as known as Bayes theorem.

Explanation of Bayes Theorem and Application Examples

To understand Bayes theorem, let’s imagine a diagram like the one in the picture.


There are four quadrants from the diagram. Variable B and its negation ¬B are people affected by spots and vice versa. The variable C and its negation ¬C symbolize people affected by smallpox and vice versa. If all are combined, it will form a set denoted by S.

Here we need to consider two variables that have not been mentioned, namely x and c (lowercase). The variable x is the probability for people affected by spots and also having smallpox, while the c variable is the chance of people getting smallpox.

With defined variables, the Bayes formula can be written:

\mathrm {prob (B | C)} = \displaystyle \frac {x}{s} = \displaystyle \frac {x}{c} \times \frac {c}{s}


\mathrm {prob} (C | B) = \displaystyle \frac {\mathrm {prob} (C)} {\mathrm {prob} (B)} \times \mathrm {prob} (B | C)

In more human readable format, we can conclude:

  • prob(C|B) = probability of a smallpox when a person has spots,
  • prob(C) = the probability of a person getting smallpox in a set,
  • prob(B|C) = probability of a person whom has spots when they gets smallpox, and
  • prob(B|¬C) = probability of a person whom has spots when they does not get smallpox.

Let’s go back to the example above using numbers.

For example prob(C) = 0.2, this means that in all communities in a city there is a 20% chance of people getting smallpox. Then suppose also prob(B|C) = 0.9 and prob(B|¬C) = 0.15, which means the possibility of people getting spots when they gets infected by smallpox is 90% and the possibility of people getting spots when he not getting smallpox is 15%.

From all that we know, we can look for the possibility of people getting spots in the city by calculating

prob(B) = prob (B|C) * prob (C) + prob (B|¬C) * prob (¬ C).

Substituting the value of the variable, we get prob (B) = 0.9 x 0.2 + 0.15 x 0.8 = 0.3. From all the variables we know above, we can get a chance of people getting smallpox when he gets spots:

\mathrm {prob (C | B)} = \displaystyle \frac {\mathrm {prob} (C)} {\mathrm {prob} (B)} \times \mathrm {prob} (B | C) = \displaystyle \frac {0.2} {0.3} \times 0.9 = 0.6.

From the results above, we can see that the chance of a person getting smallpox when they has spots is 60%. This is a pretty astonishing result, because there is a possibility that 40% of people do not have smallpox, a possibility that is quite high considering the probability of people getting spots when they have smallpox is 90%.

This is because there is a significant possibility for people to get spots and not get smallpox by prob(B|¬C), and the possibility of people getting smallpox by prob(B|C) which still has a small gap of 10%.

Bayes Theorem Application in Real Life

Bayes’s theorem is applied to the realm of law, especially civil law. For criminal law, there is still a lot of controversy about proving someone wrong with a probability.

In other parts such as weather forecasts, computer science, to machine learning, Bayes theorem is very widely applied. In addition, the unique figure of Thomas Bayes is his daily profession which is not as a mathematician, but a priest.

That is, prove that as long as we can think logically and have high curiosity, we may contribute to the development of science and technology.

To close this article, lets try to figure out the application of Bayes theory in the real world.

Suppose we work in government in the population and urban planning, we want to know the opportunities for people to ride their own motorbikes.

We use variable M for possible motor owners and G for motorbike users. Remember that motorcycle users may not necessarily own the motorbike and the motorbike owner may not necessarily use the motorbike.

Consider it prob(M) = 65%, prob(G|M) = 98% and prob (G|¬M) = 62%. What is the probability that a person own a motorcycle when they drive a motorcycle, prob (M|G)?

Leave a Reply

Your email address will not be published. Required fields are marked *