35 4 Total Prob Bayes THM
35 4 Total Prob Bayes THM
35 4 Total Prob Bayes THM
Bayes Theorem
35.4
Introduction
When the ideas of probability are applied to engineering (and many other areas) there are occasions
when we need to calculate conditional probabilities other than those already known. For example, if
production runs of ball bearings involve say, four machines, we might know the probability that any
given machine produces faulty ball bearings. If we are inspecting the total output prior to distribution
to users, we might need to know the probability that a faulty ball bearing came from a particular
machine. Even though we do not address the area of statistics known as Bayesian Statistics here, it
is worth noting that Bayes theorem is the basis of this branch of the subject.
'
Prerequisites
Before starting this Section you should . . .
&
'
%
$
Learning Outcomes
On completion you should be able to . . .
&
44
for all i
A4
A3
A5
A6
A2
Figure 10
If B is any event within S then we can express B as the union of subsets:
B = (B A1 ) (B A2 ) (B An )
The definition is illustrated in Figure 11 in which an event B in S is represented by the shaded region.
A1
A4
A3
A5
A6
A2
Figure 11
The bracketed events (B A1 ), (B A2 ) . . . (B An ) are mutually exclusive (if one occurs then none
of the others can occur) and so, using the addition law of probability for mutually exclusive events:
P(B) = P(B A1 ) + P(B A2 ) + + P(B An )
Each of the probabilities on the right-hand side may be expressed in terms of conditional probabilities:
P(B Ai ) = P(B|Ai )P(Ai )
for all i
This is the theorem of Total Probability. A related theorem with many applications in statistics can
be deduced from this, known as Bayes theorem.
HELM (2008):
Section 35.4: Total Probability and Bayes Theorem
45
2. Bayes theorem
We again consider the conditional probability statement:
P(A|B) =
P(A B)
P(A B)
=
P(B)
P(B|A1 )P(A1 ) + P(B|A2 )P(A2 ) + + P(B|An )P(An )
in which we have used the theorem of Total Probability to replace P(B). Now
P(A B) = P(B A) = P(B|A) P(A)
Substituting this in the expression for P(A|B) we immediately obtain the result
P(A|B) =
P(B|A) P(A)
P(B|A1 )P(A1 ) + P(B|A2 )P(A2 ) + + P(B|An )P(An )
This is true for any event A and so, replacing A by Ai gives the result, known as Bayes theorem as
P(Ai |B) =
P(B|Ai ) P(Ai )
P(B|A1 )P(A1 ) + P(B|A2 )P(A2 ) + + P(B|An )P(An )
3. Special cases
In the case where we consider A to be an event in a sample space S (the sample space is partitioned
by A and A0 ) we can state simplified versions of the theorem of Total Probability and Bayes theorem
as shown below.
A
A B!
AB
B A!
S
Figure 12
It is easy to see that the event B consists of the union of the (disjoint) events A B and B A0 so
that we may write B as the union of these disjoint events. We have
B = (A B) (B A0 )
Since the events A B and B A0 are disjoint, they must be independent and so
P(B) = P(A B) + P(B A0 )
46
HELM (2008):
Workbook 35: Sets and Probability
P(B|A) P(A)
P(B|A) P(A) + P(B|A0 ) P(A0 )
Example 13
At a certain university, 4% of men are over 6 feet tall and 1% of women are over
6 feet tall. The total student population is divided in the ratio 3:2 in favour of
women. If a student is selected at random from among all those over six feet tall,
what is the probability that the student is a woman?
Solution
Let M ={Student is Male}, F ={Student is Female}.
Note that M and F partition the sample space of students.
Let T ={Student is over 6 feet tall}.
We know that P(M ) = 2/5, P(F ) = 3/5, P(T |M ) = 4/100 and P(T |F ) = 1/100.
We require P(F |T ). Using Bayes theorem we have:
P(T |F )P(F )
P(T |F )P(F ) + P(T |M )P(M )
1
3
100 5
=
1
3
4
2
+
100 5 100 5
3
=
11
P(F |T ) =
HELM (2008):
Section 35.4: Total Probability and Bayes Theorem
47
Example 14
A factory production line is manufacturing bolts using three machines, A, B and
C. Of the total output, machine A is responsible for 25%, machine B for 35% and
machine C for the rest. It is known from previous experience with the machines
that 5% of the output from machine A is defective, 4% from machine B and 2%
from machine C. A bolt is chosen at random from the production line and found
to be defective. What is the probability that it came from
(a) machine A
(b) machine B
(c) machine C?
Solution
Let
D={bolt is defective},
A={bolt is from machine A},
B={bolt is from machine B},
C={bolt is from machine C}.
We know that P(A) = 0.25, P(B) = 0.35 and P(C) = 0.4.
Also
P(D|A) = 0.05, P(D|B) = 0.04, P(D|C) = 0.02.
A statement of Bayes theorem for three events A, B and C is
P(D|A)P(A)
P(D|A)P(A) + P(D|B)P(B) + P(D|C)P(C)
0.05 0.25
=
0.05 0.25 + 0.04 0.35 + 0.02 0.4
P(A|D) =
= 0.362
Similarly
P(B|D) =
0.04 0.35
0.05 0.25 + 0.04 0.35 + 0.02 0.4
= 0.406
P(C|D) =
0.02 0.4
0.05 0.25 + 0.04 0.35 + 0.02 0.4
= 0.232
48
HELM (2008):
Workbook 35: Sets and Probability
Task
An engineering company advertises a job in three newspapers, A, B and C. It
is known that these papers attract undergraduate engineering readerships in the
proportions 2:3:1. The probabilities that an engineering undergraduate sees and
replies to the job advertisement in these papers are 0.002, 0.001 and 0.005 respectively. Assume that the undergraduate sees only one job advertisement.
(a) If the engineering company receives only one reply to it advertisements,
calculate the probability that the applicant has seen the job advertised
in place A.
(i) A,
(ii) B,
(iii) C.
(b) If the company receives two replies, what is the probability that both
applicants saw the job advertised in paper A?
Your solution
HELM (2008):
Section 35.4: Total Probability and Bayes Theorem
49
Answer
Let
A = {Person is a reader of paper A},
B = {Person is a reader of paper B},
C = {Person is a reader of paper C},
R = {Reader applies for the job}.
We have the probabilities
(a)
P(A) = 1/3
P(B) = 1/2
P(C) = 1/6
P(R|A) = 0.002
P(R|B) = 0.001
P(R|C) = 0.005
P(R|A)P(A)
1
P(A|R) =
=
P(R|A)P(A) + P(R|B)P(B) + P(R|C)P(C)
3
Similarly
1
5
and
P(C|R) =
4
12
(b) Now, assuming that the replies and readerships are independent
P(B|R) =
=
3 3
1
=
9
50
HELM (2008):
Workbook 35: Sets and Probability
Exercises
1. Obtain the sample space of an experiment that consists of a fair coin being tossed four times.
Consider the following events:
A is the event all four results are the same.
B is the event exactly one Head occurs.
C is the event at least two Heads occur.
17
and explain why P(A) + P(B) + P(C) > 1.
16
2. The table below show the number of complete years a group of people have been working in
their current employment.
Show that P(A) + P(B) + P(C) =
R
C
HELM (2008):
Section 35.4: Total Probability and Bayes Theorem
D
51
6. From a batch of 100 items of which 20 are defective, exactly two items are chosen, one at a
time, without replacement. Calculate the probabilities that:
(a) the first item chosen is defective
(b) both items chosen are defective
(c) the second item chosen is defective.
7. A garage mechanic keeps a box of good springs to use as replacements on customers cars. The
box contains 5 springs. A colleague, thinking that the springs are for scrap, tosses three faulty
springs into the box. The mechanic picks two springs out of the box while servicing a car. Find
the probability that:
(a) the first spring drawn is faulty
8. Two coins are tossed. Find the conditional probability that two Heads will occur given that at
least one occurs.
9. Machines A and B produce 10% and 90% respectively of the production of a component
intended for the motor industry. From experience, it is known that the probability that machine
A produces a defective component is 0.01 while the probability that machine B produces a
defective component is 0.05. If a component is selected at random from a days production
and is found to be defective, find the probability that it was made by
(a) machine A
(b) machine B.
Answers
1. P(A) =
2
4
11
, P(B) = , P(C) = ,
16
16
16
17
16
A, B and C are not mutually exclusive since events A and C have outcomes in common. This
17
is the reason why P(A) + P(B) + P(C) = ; we are adding the probabilities corresponding
16
to common outcomes more than once.
2. (a) P(person falls in the modal group) =
15
50
27
50
8
(c) P(person has been working for more than 8 years) =
50
3. P(A) P(B) =
1
3
and (1 P(A)) (1 P(B)) =
8
8
1
2
(or
1
) and
4
1
3
and (1 x)(1 y) = and solve to get:
8
8
P(B) =
1
4
(or
1
)
2
52
HELM (2008):
Workbook 35: Sets and Probability
Answers
5. P((A B) (C D)) = P(A B) + P(C D) P(A B C D)
= p2 + p2 p4
= 2p2 p4
6. Let A={first item chosen is defective}, B ={second item chosen is defective}
(a) P(A) =
20
1
=
100
5
19
20
19
=
99 100
495
19
20
20
80
198
1
(c) P(B) = P(B|A)P(A) + P(B|A0 )P(A0 ) =
=
=
99 100 99 100
990
5
3
8
2 3 3 5
21
3
+ =
=
7 8 7 8
56
8
P(A B)
P(A) P(B)
1
2 2
P(B) =
=
=
=
1 1 1 1
P(A B)
P(A) + P(B) P(A) P(B)
3
+
2 2 2 2
9. Let A = {item from machine A}, B = {item from machine B}, D = {item is defective}.
We know that: P(A) = 0.1, P(B) = 0.9, P(D|A) = 0.01, P(D|B) = 0.05.
(a)
P(D|A)P(A)
P(D|A)P(A) + P(D|B)P(B)
0.01 0.1
=
0.01 0.1 + 0.05 0.9
= 0.02
P(A|D) =
HELM (2008):
Section 35.4: Total Probability and Bayes Theorem
53