0% found this document useful (0 votes)
137 views3 pages

Bayes' Theorem in Disease Testing

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views3 pages

Bayes' Theorem in Disease Testing

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Bayes theorem

A doctor wants to determine the probability that a patient has a certain disease based on the
results of a medical test.

Information:

 The disease affects 1% of the population (P(Disease)=0.01P(\text{Disease}) =


0.01P(Disease)=0.01).
 The test is 90% accurate, meaning if a person has the disease, the test will correctly
identify it 90% of the time (P(Positive Test∣Disease)=0.9P(\text{Positive Test} | \
text{Disease}) = 0.9P(Positive Test∣Disease)=0.9).
 The test also has a false positive rate of 5%, meaning it will incorrectly identify the
disease in 5% of healthy individuals (P(Positive Test∣No Disease)=0.05P(\
text{Positive Test} | \text{No Disease}) = 0.05P(Positive Test∣No Disease)=0.05).

Step 1: Calculate the Prior Probability

From the problem, we know:

 P(Disease)=0.01P(\text{Disease}) = 0.01P(Disease)=0.01
 P(No Disease)=1−P(Disease)=0.99P(\text{No Disease}) = 1 - P(\text{Disease}) =
0.99P(No Disease)=1−P(Disease)=0.99

Step 2: Calculate the Total Probability of a Positive Test

To find P(Positive Test)P(\text{Positive Test})P(Positive Test), we use the law of total


probability:

P(Positive Test)=P(Positive Test∣Disease)⋅P(Disease)+P(Positive Test∣No Disease)⋅P(No Dis


ease)P(\text{Positive Test}) = P(\text{Positive Test} | \text{Disease}) \cdot P(\text{Disease})
+ P(\text{Positive Test} | \text{No Disease}) \cdot P(\text{No
Disease})P(Positive Test)=P(Positive Test∣Disease)⋅P(Disease)+P(Positive Test∣No Disease
)⋅P(No Disease)

Substituting the values:

P(Positive Test)=(0.9⋅0.01)+(0.05⋅0.99)P(\text{Positive Test}) = (0.9 \cdot 0.01) + (0.05 \


cdot 0.99)P(Positive Test)=(0.9⋅0.01)+(0.05⋅0.99) =0.009+0.0495=0.0585= 0.009 + 0.0495 =
0.0585=0.009+0.0495=0.0585

Step 3: Apply Bayes' Theorem

Now we can calculate the posterior probability, P(Disease∣Positive Test)P(\text{Disease} | \


text{Positive Test})P(Disease∣Positive Test):

P(Disease∣Positive Test)=P(Positive Test∣Disease)⋅P(Disease)P(Positive Test)P(\


text{Disease} | \text{Positive Test}) = \frac{P(\text{Positive Test} | \text{Disease}) \cdot P(\
text{Disease})}{P(\text{Positive
Test})}P(Disease∣Positive Test)=P(Positive Test)P(Positive Test∣Disease)⋅P(Disease)

Substituting in the known values:

P(Disease∣Positive Test)=0.9⋅0.010.0585P(\text{Disease} | \text{Positive Test}) = \frac{0.9 \


cdot 0.01}{0.0585}P(Disease∣Positive Test)=0.05850.9⋅0.01 =0.0090.0585≈0.1538= \
frac{0.009}{0.0585} \approx 0.1538=0.05850.009≈0.1538

Conclusion

The probability that the patient actually has the disease given that they received a positive test
result is approximately 15.38%. This result highlights the importance of considering both the
accuracy of the test and the prevalence of the disease when interpreting medical test results.

Email Spam Detection

Scenario: An email spam filter uses Bayesian methods. It knows that:

 20% of emails are spam (P(S)=0.2P(S) = 0.2P(S)=0.2).


 If an email is spam, there’s an 80% chance it contains the word "win"
(P(W∣S)=0.8P(W | S) = 0.8P(W∣S)=0.8).
 If an email is not spam, there’s a 10% chance it contains the word "win"
(P(W∣¬S)=0.1P(W | \neg S) = 0.1P(W∣¬S)=0.1).

Questions:

1. What is the probability that an email is spam given that it contains the word "win"?
2. What is the probability that an email is not spam given that it contains the word
"win"?

Step 1: Define the Events

Let:

 SSS: the event that an email is spam.


 WWW: the event that the email contains the word "win".

Step 2: Given Probabilities

 P(S)=0.2P(S) = 0.2P(S)=0.2
 P(W∣S)=0.8P(W | S) = 0.8P(W∣S)=0.8
 P(W∣¬S)=0.1P(W | \neg S) = 0.1P(W∣¬S)=0.1
 P(¬S)=1−P(S)=0.8P(\neg S) = 1 - P(S) = 0.8P(¬S)=1−P(S)=0.8
Step 3: Total Probability of an Email Containing "Win"

Using the law of total probability:

P(W)=P(W∣S)⋅P(S)+P(W∣¬S)⋅P(¬S)P(W) = P(W | S) \cdot P(S) + P(W | \neg S) \cdot P(\neg


S)P(W)=P(W∣S)⋅P(S)+P(W∣¬S)⋅P(¬S)

Calculating:

P(W)=(0.8⋅0.2)+(0.1⋅0.8)P(W) = (0.8 \cdot 0.2) + (0.1 \cdot 0.8)P(W)=(0.8⋅0.2)+(0.1⋅0.8)


=0.16+0.08=0.24= 0.16 + 0.08 = 0.24=0.16+0.08=0.24

Step 4: Apply Bayes' Theorem

To find P(S∣W)P(S | W)P(S∣W):

P(S∣W)=P(W∣S)⋅P(S)P(W)P(S | W) = \frac{P(W | S) \cdot P(S)}


{P(W)}P(S∣W)=P(W)P(W∣S)⋅P(S)

Substituting the values:

P(S∣W)=0.8⋅0.20.24P(S | W) = \frac{0.8 \cdot 0.2}{0.24}P(S∣W)=0.240.8⋅0.2


=0.160.24≈0.6667= \frac{0.16}{0.24} \approx 0.6667=0.240.16≈0.6667

Conclusion for Part 1: The probability that an email is spam given that it contains the word
"win" is approximately 66.67%.

Step 5: Probability of Not Being Spam Given "Win"

To find P(¬S∣W)P(\neg S | W)P(¬S∣W):

Using the complement rule:

P(¬S∣W)=1−P(S∣W)≈1−0.6667=0.3333P(\neg S | W) = 1 - P(S | W) \approx 1 - 0.6667 =


0.3333P(¬S∣W)=1−P(S∣W)≈1−0.6667=0.3333

Conclusion for Part 2: The probability that an email is not spam given that it contains the
word "win" is approximately 33.33%.

You might also like