Probability theory: Bayes’ theorem

This is part of the course “Probability Theory and Statistics for Programmers”.

Image for post
Image for post
Probability Theory For Programmers

Bayes’ theorem looks like this:

Image for post
Image for post

Where A and B are events.

P(A|B) —the likelihood of event A occurring after B is tested

P(B|A) — the likelihood of event B occurring after A is tested

P(A) and P(B) — probabilities of events A and B

One of the most popular examples is calculating the probability of having a rear disease. Let’s imagine that some person comes back from an exotic country and want to check, does he have this country rear disease. He took a test and got 0.9 that he has a disease, given that the test has 0.99 probability of giving the right result. Also, this disease is very unlikely to occur, since only 0.0001 people returning from the country have the disease.

P(A|B) — the probability that a person has a disease—?

P(B|A) — the probability that person has a disease(after he took a test)— 0.9

P(A) — the probability that a person can have a disease — 0.0001

P(B) —the probability that the test gave a true result — ?

Let’s calculate P(B) with “The Law Of Total Probability”:

Image for post
Image for post

Now we can calculate P(A|B):

Image for post
Image for post

After calculating real probability we can see that real probability quite differs from probability, given by disease test. Now, in order to find a better probability, the person can go to other disease test providers and try to find a more precise probability. Because now he will use 0.0009 rather than 0.0001 as P(A).

Next part ->

Reach the next level of focus and productivity with increaser.org.

Image for post
Image for post
Increaser

Written by

Software engineer, creator of increaser.org. More at geekrodion.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store