Bayes Formula/Bayes Law/Bayes Rule

Bayes formula describes the probability of an event based on prior knowledge of conditions that might be related to the event.

Bayes theorem describes how to adjust your believes based on available evidence.

Bayes theorem is particularly useful when you do tests to determine what the chances are that a positive test result is accurate. Most examples are also based on this. For example, what is the chances that a person that tested positive for HIV or cancer, actually have HIV or cancer. This sounds ridicilous at first, but it is surprising at just how inaccurate these test results are.

P(A|B) = ( P(B|A) P(A) )/P(B)

where:

  • P(A|B) is the probability that A is true, given that B is true
  • P(B|A) is the probability that B is true, given that A is true
  • P(A) is the probability of A being true
  • P(B) is the probability of B being true

Steps:

  1. Determine what you want to find
  2. Write down the formula
  3. Find each ingredient and label it
  4. Plug each ingredient into the formula and solve for it

For Example:

Drug Testing

  • A drug test will produce a true positive result for 99% of drug users
  • A drug test will produce a true negative result for 99% of the non users of the drug
  • 0.5% of the population uses this drug

What do we want to find?

What is the probability that a random test with a positive result is actually a user of the drug

Write down the formula:

P(USER|+) = ( P(+|USER)P(USER) )/P(+)

P(+) can be written as P(+|USER)P(USER) + P(+|NON-USER)P(NON-USER)

so

Find every ingredient and label it:

P(+|USER) = 0.99

P(USER) = 0.005

P(+|NON-USER) = 1 – 0.99 = 0.01

P(NON-USER) = 1 – 0.005 = 0.995

Plug each ingredient into the formula and solve for it

P(USER|+) = ( 0.99 x 0.005 )/ ( (0.99 x 0.005) + (0.01 x 0.995))

= 33.2%

So despite how accurate the test is, if a person tests positive, there is only a 1 out of 3 chance they may actually be guilty. There is a 2/3 chance that they are innocent and that the test produced a false positive.

References:

WikiPedia

Bayes Theorem – A Visual Introduction for Beginners by Dan Morris

Bayesian Statistics: From Concept to Data Analysis | University of California, Santa Cruz