Bayes' theorem is a theorem used to calculate the probability of something being true, false, or a certain way. Bayes' theorem is an extension of logic. It expresses how a belief should change to account for evidence. Bayes' theorem is as follows:

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

P(A|B) represents the probability that a given B is A.

P(A|B) represents the probability that a given A is B.

P(A) represents the probability that A is true.

P(B) represents the probability that B is true.

Bayes' theorem can also be written as follows, in order to calculate the probability of P(B):

**P(A/B) = P(B|A) * P(A) / [ P(B|A) * P(A) + P(B|notA) * P(notA) ]**

## Example problemEdit

Suppose that 1% of a given population has a disease. With this disease, there is a screening method to see if a given individual has it. In individuals who have the disease, they test positive 90% of the time. For individuals who do not have it, they test positive 20% of the time, and thus are false positives. For a given individual who tested positive, what is the probability that person actually has the disease?

P(A|B) represents the probability that a given individual who tested positive actually has the disease.

P(B|A) represents the probability that a given individual who has the disease tests positive. This probability is 90%.

P(A) represents the probability that a given individual has the disease. This probability is 1%.

Thus, P(B|A) * P(A) represents the probability that a given individual has the disease, and tested as positive for it. This probability is .01 * .9, which equals .009, or 0.9%.

P(B) represents the probability that a given individual tested positive for the disease.

In order to find out the probability of P(B), we must figure out the probability that a given individual does NOT have the disease, but falsely tests positively for it, using the same method as used above. This probability is .99 * .2 which equals .198, or 19.8%.

We then add this to the probability that an indidual has the disease and tests positive, giving us the total probability that a given individual tests positive for the disease.

19.8 percent of people test positive for the disease, but only 0.9% of people who test positive actually have it. We then input these numbers. .009 / .198

Therefore, if a given individual tests positive, the chance that they actually have the disease is about **4.5%**.