7 Posterior Probability and Bayes PDF
7 Posterior Probability and Bayes PDF
7 Posterior Probability and Bayes PDF
Examples:
1. In a computer installation, 60% of programs are written in C ++
and 40% in Java. 60% of the programs written in C ++ compile
on the first run and 80% of the Java programs compile on the first
run.
(a) What is the overall proportion of programs that compile on
first run?
(b) If a randomly selected program compiles on the first run what
is the probability that it was written in C ++ ?
2. In a certain company
Line 1 2 3 4 5
% received 20 30 10 15 25
Line 1 2 3 4 5
% exceeding
100 characters 40 60 20 80 90
P (C ++ )P (E|C ++ )
P (C ++ |E) =
P (E)
Bayes’ Rule
Bayes’ rule for two events
Consider two events A and B.
P (A ∩ B) = P (A)P (B|A)
and
P (B ∩ A) = P (B)P (A|B)
Since
P (A ∩ B) = P (B ∩ A),
It follows from the multiplication law that
Let:
R0 is event that a zero is received.
T0 is event that a zero is transmitted, P (T0 = .7)
Now:
P (T0 )P (R0 |T0 ) = .7 × .95
and
R0 = (T0 ∩ R0 ) ∪ (T1 ∩ R0 )
So
P (R0 ) = P (T0 )P (R0 |T0 ) + P (T1 )P (R0 |T1 )
Therefore
P (R0 ) = .7 × .95 + .3 × .25 = .74
.7 × .95 .665
P (T0 |R0 ) = = = .90
.7 × .95 + .3 × .25 .74
Similarly
.3 × .25 .075
P (T1 |R0 ) = = = .10
.7 × .95 + .3 × .25 .74
Example
• P (W ord) = .5;
• P (Latex) = .3;
• P (Html) = .2.
40% of the WORD documents exceed 10 pages
20% of the LATEX documents exceed 10 pages
20% of the HTML exceed 10 pages
A a document chosen at random was found to exceed 10 pages, what
the probability is that it has been written in Latex?
P (Latex|E) =?
P (Latex)P (E|Latex)
P (Latex|E) =
P (E)
Now
P (Ai )P (E|Ai )
P (Ai |E) =
P (E)
E ∩ Ai = Ai ∩ E
P (E)P (Ai |E) = P (Ai )P (E|Ai )
P (Ai )P (E|Ai )
P (Ai |E) =
P (E)
• Machine Learning
• Machine Translation
Game Show:
So we can write
P (D3 )P (E|D3 )
P (D3 |E) =
P (D1 )P (E|D1 ) + P (D2 )P (E|D2 ) + P (D3 )P (E|D3 )
(1)
We need to calculate P (E|D1 ), P (E|D2 ) and P (E|D3 ).