**1. Explanation **
Bayes Theorem: To find the probability of event B, given A occurs
P(D|T) = P(T|D)*P(D)/P(T)
* One may think that T is a test or diagnosis, and D is a disease infection

P(D|T) = probability that D occurs, given T positive (posterior probability)

P(T|D) = True positive rate of T occurs given D occurs

P(T|-D) = False positive of T (Test positive but D does not occurs)

P(D) = Probability that D occurs

P(-D) = Probability that D does not occur = 1-P(D)

P(T) = Total probability that E occurs which includes both the true positive and false positive part of T, i.e.
P(T) = P(T|D).P(D) + P(T|-D).P(-D)
**2. Example Problems**

**Medical Test Accuracy**

**Problem**:

A particular disease affects 1% of a population. A diagnostic test for this disease is 95% accurate, meaning:

• If a person has the disease, the test correctly identifies it 95% of the time (True Positive Rate).

• If a person does not have the disease, the test correctly identifies that they do not have it 90% of the time (True Negative Rate).

What is the probability that a person who tested positive actually has the disease?

P(D|T) = ? P(T|D) = 0.95 (True Positive) P(T|-D) = 1-0.90 = 0.10 (False Positive) because P(T-|-D) = 0.90 P(D) = 0.01 P(-D) = 1-P(D) = 0.99

P(T) = P(T|D)P(D) + P(T|-D)P(-D) = 0.95*0.01 + 0.10*0.99 = 0.1085 P(D|T) = 0.95*0.01/0.1085 = 0.0876

**Spam Email Classification**

**Problem**:

Suppose 4% of the emails in your inbox are spam. A spam filter correctly identifies 98% of spam emails and incorrectly identifies 5% of non-spam emails as spam.

What is the probability that an email marked as spam by the filter is actually spam?

P(S|F) = ? P(F|S) = 0.98 (True Positive) P(F|-S) = 0.05 (False Positive) P(S) = 0.04 P(-S) = 1-P(S) = 0.96

P(F) = P(F|S)P(S) + P(F|-S)P(-S) = 0.98*0.04 + 0.05*0.96 = 0.0872 P(S|F) = 0.98*0.04/0.0872 = 0.4495

**House Inspection**

From the record of house inspector to detect house defect,

the probability of positive defective = 0.9, false defective = 0.10

The probability that general house is defective = 0.20

The probability that any house is defective is 0.10

Find the probability that my house is defective once testing show defective P(D|T) = ? P(T|D) = 0.90 (True defective) P(T|-D) = 0.10 (False defective) P(D*) = 0.10 (My house is defective) P(D) = Probability that any house is defective = 0.20 P(-D) = 1-P(D) = 0.80

P(T) = P(T|D)P(D) + P(T|-D)P(-D) = 0.90*0.20 + 0.10*0.80 = 0.26 P(D|T) = 0.9*0.10/0.26= 0.346

In this case the probabity of my house is defective is used in P(D) as we have specific information.

**Hint: **
It's good to keep this template in mind to solve problem using Bayes Theorem. One is Bad thing like mail spam, disease and another is filter or test to screen out such bad thing. __The quesiton is what is the probability that the bad thing could happen given test is positive, or vice versa.__

## Comments