# Bayes Theorem and It’s Calculation Example

In real life, we face various probabilistic events; for instance, nearly 25% of people are getting infected by Covid-19, and there is a 1-3% mortal rate of this disease. It may look intimidating at first glance, but if it is broken down more intuitively, then it would be less scary

In mathematics, we have a nice theory to cover these probabilistic events called Bayes Theorem. It is a theorem in probability used to calculate one event’s probability given the other event has occurred.

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

\begin{aligned}
P(A|B) = \frac{P(B|A)* P(A)} {P(B)}
\end {aligned}
• P(A|B) = Probability of event A is happening given that event B does happen
• P(A) = Probability of event A is happening independently
• P(B) = Probability of event B is happening independently
• P(B|A) = Probability of event B is happening given that event A does happen

I am a fan of teaching by real life example. So in this case I will try to give an example

Question

Approximately 1% of women aged 40-50 have breast cancer. A woman with breast cancer has a 85% chance of a positive test from a mammogram, while a woman without has a 15% chance of a false positive result. What is the probability a woman has breast cancer given that she just had a positive test?

P(Test=Positive | Cancer=True) = 0.85

From the above statement, our intuition may suggest an 85% chance that the patient has cancer. But we would fall into the trap of base rate fallacy if we do not consider the other variables like the probability of cancer having cancer in that selected group of people, P(Cancer=True) = 1%.

So from Bayes theorem we get that

P(Cancer=True | Test=Positive) = P(Test=Positive|Cancer=True) * P(Cancer=True) / P(Test=Positive)

\begin{aligned}
P(C|pos) = \frac{P(pos|C)* P(C)} {P(pos)}
\end {aligned}

here, P(pos|C) = 0.85, P(C) = .01, but here P(pos) is not provided.

\begin{aligned}
P(pos) = {P(pos|C)* P(C)} + {P(pos|C-)*P(C-)}
\end {aligned}

P(C-) = Probability of not having Cancer = 1-.01 = 0.99

P(pos|C-) = 0.15

Finally

\begin{aligned}
P(C|pos) = \frac{P(pos|C)* P(C)} {{P(pos|C)* P(C)} + {P(pos|C-)*P(C-)}}
\end {aligned}
\begin{aligned}
P(C|pos) = \frac{0.85* 0.01} {{(0.85* 0.01)} + {(0.15*0.99})}
\end {aligned}
\begin{aligned}
P(C|pos) = 0.541
\end {aligned}

So P(C|pos) = 5.41%

For easier calculation I have added one calculator here