# Bayes` Theorem and examples-Word ```6.3: Bayes Theorem
We can use Bayes Theorem when we know some conditional probabilities, but wish to know others.
For example: We know P(test positive|have disease), and we wish to know P(have disease|test positive)
Ex. 1 (book ex 2- p. 419) Suppose that one person in 100,000 has a particular rare disease for which there is a fairly
accurate diagnostic test. This test is correct 99% of the times for someone who has the disease and 99.5%% of the time
for someone who does not.
Let F=event one has the disease
E=event one tests positive
We know that P(F) = 1/100,000 = .00001
P(E|F)= P(positive|disease) = .99 and
P( 𝐸̅ | 𝐹̅ ) = P(negative| don’t have disease) = .995
Determine
P(F|E) = P(has disease|test positive) = ___
and
P (𝐹̅ | 𝐸̅ )= P(does not have disease |test negative)= ___
P(E|F)
F
̅̅̅
P(E|𝐹)
(0.99)(0.00001)
P(F|E) = (0.99)(0.00001)+(0.005)(0.99999) = 0.002
P(𝐹̅ |𝐸̅ ) =
(0.995)(0.99999)
(0.995)(0.99999)+(0.01)(0.00001)
= 0.9999999
Bayes Theorem: Suppose the E and F are events from a sample space S such that p(E)≠0 and p(F) ≠0. Then
P(F|E) =
𝑝(𝐸 |𝐹 )𝑝(𝐹)
̅ )𝑝(𝐹̅)
𝑝(𝐸 |𝐹 )𝑝(𝐹)+(𝐸 |𝐹
Ex. 2: F=studied for final, E=passed class
Assume:
P(F) = P(studied)=.8
P(E|F)= P(passed|studied)=.9 and
P(E| 𝐹̅ ) = P(passed|didn’t study)=.2
Find
P(F|E) = P(studied|passed)= ___
P (𝐹̅ | 𝐸̅ )= P(didn’t study | failed) = ___
P(E|F)
F
̅̅̅
P(E|𝐹)
Ex. 3: Spam filters
Idea: spam has words like “offer”, “special”, “opportunity”, “Rolex”, …
Non-spam has words like “mom”, “lunch”,…
False negatives: when we fail to detect spam
False positives: when non-spam is seen as spam
Let S=spam
E=has a certain word
Assume P(S)=0.5
P(S|E) =
𝑝(𝐸 |𝑆 )𝑝(𝑆)
𝑝(𝐸 |𝑆)𝑝(𝑆)+(𝐸 |𝑆̅)𝑝(𝑆̅)
P(E|S)
S
̅̅̅
P(E|𝑆)
Consider that “Rolex” occurs in 250/2000= .125 spam messages and in 5/1000=.005 non-spam messages. Assume
P(S)=0.5
(.5)(.125)
Ex: P(S|uses word “Rolex”) = (.5)(.125)+(.5)(.005) = .962
```