Bayess
Bayess
This quick handout is dedicated to our Mathematics teacher who works tirelessly for us to get a better
education SIR SHAFII ATHUMANI.
Bayes’ theorem, named after 18th century British mathematician Thomas Bayes, a Mathematical formula
for determining conditional probability.
Conditional probability is the probability in which occurrence of one event depends on occurrence of the
other. Thus, Bayes’ theorem provides way to revise existing predictions or theories given new or additional
evidence.
From conditional probability of two events let say event A and B we have,
𝑃(𝐴 ⋂ 𝐵) 𝑃(𝐴∩𝐵)
P(𝐴⁄𝐵 ) = 𝑃(𝐵)
and P(𝐵⁄𝐴) = 𝑃(𝐴)
Making subject of the formula P(A∩ 𝐵) then equating those two equations will give
Taking 𝑃(𝐴⁄𝐵) × 𝑃(𝐵) = 𝑃(𝐵⁄𝐴) × 𝑃(𝐴) divide by 𝑃(𝐵) both sides give
𝑃(𝐵⁄𝐴) × 𝑃(𝐴)
𝑃(𝐴⁄𝐵) =
𝑃 (𝐵)
This is the basic formula for BAYES’ THEOREM. Therefore, this theory helps to find the conditional
probability whose reverse conditional probability is known.
Identify the normal probability, normal probability is when you are provided with two or
more source of events and they actually have equal probability unless specified otherwise.
Example assume you are provided with two urns A and B containing three red marbles and
five blue marbles in urn A and two red marbles and four blue marbles in the other
urn…….thus the probability (normal probability) of drawing a marble from either of the
two urns is 1⁄2 or 0.5. In other cases you might be given that the chance of drawing a
marble from urn A is 40%.......which implies that the normal probability of drawing a
marble from urn A is 0.4 and that of B is 1-0.4 = 0.6.
Identify conditional probability in a given problem, this is the probability of choosing
element from something (source) ,example the probability of choosing red marbles from
urn or box A.
Use suitable tree diagram .
Apply BAYES’ formula to obtain the reverse conditional probability.
1. Two boxes, first box contains 2 white and 3 red balls and the second box contains 4 white and 5 red
balls. One of the balls is drawn at random from one of the box and is found to be red, find the
probability that it was drawn from second box.
Solution
In this question the chance for a ball to be drawn from any of the two boxes is equal, thus normal
probability of the box is 1⁄2 .
Conditional probability of this question is that the drawn red ball maybe from first or second box with
corresponding probabilities of …
Let’s say first box be A and the second be B to make it more simple on notation of their probability
And the red ball be represented by letter R
𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑟𝑒𝑑 𝑏𝑎𝑙𝑙𝑠 𝑝𝑟𝑒𝑠𝑒𝑛𝑡 𝑖𝑛 𝑏𝑜𝑥 𝐴 3
The probability that the red ball comes from box A, P(𝑅 ⁄𝐴) = 𝑡𝑜𝑡𝑎𝑙 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑏𝑎𝑙𝑙𝑠 𝑖𝑛 𝑏𝑜𝑥 𝐴
=5
𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑟𝑒𝑑 𝑏𝑎𝑙𝑙𝑠 𝑝𝑟𝑒𝑠𝑒𝑛𝑡 𝑖𝑛 𝑏𝑜𝑥 𝐵 5
The probability that the red ball comes from box B, P(𝑅 ⁄𝐵) = 𝑡𝑜𝑡𝑎𝑙 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑏𝑎𝑙𝑙𝑠 𝑖𝑛 𝑏𝑜𝑥 𝐵
=9
Required to calculate is the probability that red ball has already occur and it is from second box that
means it is the probability that of second box given red occur , P(𝐵⁄𝑅)
From Bayes’ formula
1 5
× 25
2 9
𝑃(𝐵⁄𝑅) = 26 = 52
45
25
⸫The probability that the red ball was drawn from a second box is 52
2. Three girls, Aileen, Barbara and Cathy, pack biscuits in a factory. From the batch allotted to them
Aileen packs 55%, Barbara 30% and Cathy 15%. The probability that Aileen breaks some biscuits in a
packet is 0.7, and the respective probabilities for Barbara and Cathy are 0.2 and 0.1. What is the
probability that the packet with broken biscuits found by the checker was packed by Aileen.
Solution.
Let A be the event ‘the packet was packed by Aileen’, B be the event ‘the packet was packed by
Barbara’, C be the event ‘the packet was packed by Cathy’, D be the event ‘the packet contains broken
biscuits’.
We are given P(A) = 0.55, P(B) = 0.3, P(C) = 0.15 and
P(𝐷⁄𝐴) = 0.7, P(𝐷⁄𝐵 ) = 0.2 , P(𝐷⁄𝐶) = 0.1.
We need to find the probability that the packet containing broken biscuit found by the checker was packed
by Aileen that is….it is the probability that Aileen packed the broken biscuits given the broken biscuit has
already found by the checker , P(𝐴⁄𝐷), so we use Bayes’ theorem to ‘reverse the conditions’:
𝑃(𝐷⁄𝐴) × 𝑃(𝐴)
𝑃(𝐴⁄𝐷) =
𝑃 (𝐷)
Thus can be found very easily from the tree diagram. The outcomes resulting in a packet with broken
biscuits are shown with an asterisk.
State of biscuits
P(D/A) = 0.7 *P(D/A)P(A) = (0.7)(0.55)
Packer
P(D/B) = 0.2
P(B) = 0.3 *P(D/B)P(B) = (0.2)(0.3)
P(D’/B) = 0.8
P(C) = 0.15
P(D/C) = 0.1 *P(D/C) P(C) = (0.1)(0.15)
P(D’/C) = 0.9
P(D) = P(D/A)P(A) + P(D/B)P(B) + P(D/C)P(C)
= 0.46
P(D/A)P(A) = (0.7)(0.55)
0.7×0.55 77
Then P(A/D) = =
0.46 92
= 0.837 ( 3 d.p )
⸫The probability that a packet with broken biscuits was packed by Aileen is 0.837 (3 d.p)
3. Three children, Catherine, Michael and David , have equal plots in a circular patch garden. The boundaries
are marked out by pebbles. Catherine has 80 red and 20 white flowers in her patch, Michael has 30 red and
40 white flowers and David has 10 red and 60 white flowers. Their young sister, Mary, wants to pick a
flower for her teacher.
(a) Find the probability that she picks a red flower if she chooses a flower at random from the garden,
ignoring the boundaries.
(b) Find the probability that she picks a red flower if she first chooses a plot at random.
(c) If she chooses a flower by the method described in (b), find the probability that it comes from
Michael’s plot.
Solution
(a) If the boundaries are ignored:
The possibility space S = (flowers in the garden)
And n(S) = 100+70+70 = 240
Let R be the event ‘a red flower is chosen’ ,then
n(R) = 80+30+10 =120
30 1
*P(R/M)P(M) = ×
70 3
P(M) = ⅓
10 1
*P(R/D)P(D) = ×
70 3
16
= 35
16
The probability that Mary picks a red flower if she chooses a plot at random first is 35
NOTE : The two different result from part (a) and part (b) are slightly surprising. In the first case, there is one group flowers
because the whole circular patch was considered as single plot and thus each flower is equally likely to be chosen. In the
second case, even though each plot is equally likely to be chosen, the proportion of red and white flowers within these plots
are different.
16
And P(R) = 35 (from part (b))
1
7 5
Therefore, P(M/R) = 16 =
16
35
5
Given that picks a flower, the probability that it came from Michael’s plot is .
16
1
4. I travel to work by route A or route B. The probability that I choose route A is . The probability that I am late for
4
2 1
work if I go via rout A is 3 and the corresponding probability if I go via route B is 3 .
(a) What is the probability that I am late for work on Monday?
(b) Given that I am late for work, what is the probability that I went via route B?
Solution .
(a) The probability of being late for work on Monday
The probability of being late for work is independent of the days in a week thus the probability of being late
at work on particular day, Monday, is equal to the probability of being late for work on any day depending
on the route used to arrive at work.
Let A be the event ‘I choose route A’ and B be the event ‘I choose route B’ also L be the event ‘I am late for
work’.
The outcomes in event L are shown with an asterisk on the tree diagram.
Arrival
1 2
Route *P(L/A)P(A) = ×
2 4 3
P(L/A)=
3
1
P(A)=
4
9
1 3
*P(L/B)P(B) = ×
1 3 4
3
P(L/B)=
3
P(A)=
4
5
The probability that I am late for work on Monday is .
12
Screening test
Men *P(D/C)P(C) = 0.95 × 0.12
P(D/C)= 0.95
P(C)= 0.12
The probability that a man has cancer given that, he has positive result, P(C/D)
By using Bayes’ theorem to ‘reverse the conditions’9
𝑃(𝐷⁄𝐶) × 𝑃(𝐶)
𝑃(𝐶 ⁄𝐷) =
𝑃(𝐷)
= 0.144
0.114
Therefore P(C/D) = 0.1668
95
= = 0.683 (3 𝑑. 𝑝)
139
The probability that a man has cancer given that he has positive result is 0.683 (3 𝑑. 𝑝).
6. Of the buses leaving the bus station each day, 60% are double deckers and the rest are single deckers;
30% of the double deckers are ‘limited stop’ and 40% of the single deckers are ‘limited stop’ buses.
Draw a tree diagram to represent this information . Find the probability that a bus leaving the station
(a) Is not a ‘limited stop’ bus.
(b) Is a double decker, given that it is a ‘limited stop’ bus.
Solution.
Let D be the event ‘double deckers bus leaving the station’ and S be the event ‘single deckers bus
leaving the station’
And L be the event ‘the bus is ‘limited stop’’
We are given P(D)=0.6, P(S)=0.4, P(L/D)=0.3, and P(L/S)=0.4
The outcomes are displayed with an asterisk on the tree diagram below.
Limit status
Type of bus *P(L/D)P(D) = 0.3 × 0.6
P(L/D)= 0.3
P(D)= 0.6
P(L’/D)= 0.7 *P(L’/D)P(D) = 0.7 × 0.6
P(L’/S)= 0.6
*P(L’/S)P(S) = 0.6 × 0.4
𝑃(𝐿⁄𝐷) × 𝑃(𝐷)
𝑃(𝐷⁄𝐿) =
𝑃(𝐿)
9
= 17
9
The probability that the bus leaving the station is double deckers given that it is a ‘limited stop’ bus is 17.
7. Susan takes examinations in mathematics, French and history. The probability that she passes
mathematics is 0.7 and the corresponding probabilities for French and history are 0.8 and 0.6 . Given
that her performance in each subject are independent, draw the tree diagram to show the possible
outcomes. Find the probability that Susan
(a) Fails all three examinations.
(b) Fails just one examination.
(c) Given that Susan fails just one examination, find the probability that she fails history.
Solution.
Let M, F and H be the event that ‘Susan takes Mathematics, French and History examinations respectively’
And P and P’ be the corresponding events that ‘Susan passes and fails a particular examination’
P(F/M) = 0.3
Mathematics
9(
P(P/F) = 0.8
French
9(
P(P’/F) = 0.2
History 9(
P(P/H) = 0.6
9(
P(P’/H) = 0.4
9(
PREPARED BY YUSSUF HAMOUD & ALLY OMAR
9
9(
(a) The probability that Susan fails all three examinations, P(P’)
Given that, the performance in each subject are indecent
P(P’) = P(P’/M) × P(P’/F) × P(P’/H)
= 0.3 × 0.2 × 0.4
= 0.024
The probability that Susan fails all three examinations is 0.024.
(b) The probability that Susan fails just one examination, P(P’1)
P(P’1) = ( P(P’/M)×P(P/H)×P(P/F) ) + ( P(P/M)×P(P’/H)×P(P/F) ) + ( P(P/M)×P(P/H)×P(P’/F) )
= 0.3×0.8×0.6 + 0.7×0.2×0.6 + 0.7×0.8×0.4
= 0.452
The probability that Susan fails just one examination is 0.452.
(c) The probability that Susan fails history given that she fails just one examination
Let the probability that Susan fails just history be P(Hf) = P(P’/H)×P(P/M)×P(P/F)
= 0.4×0.8×0.7
= 0.224
𝑃(𝑃′1 / 𝐻𝑓)𝑃(𝐻𝑓)
Thus P(Hf /P’1 ) = 𝑃(𝑃′1 )
Now𝑃(𝑃 ′1 / 𝐻𝑓 )𝑃(𝐻𝑓 ) = P(Hf) = 0.224
= 0.496 (3 d.p )
The probability that Susan fails History given that she fail just one examination is 0.496
This is true for all other examination when asked to fail one or two examination . On your
own you should be able to calculate the probability that she fails Mathematics given that
she fails just one subject as well as for French.
8. A bag contains 10 counters of which 4 are pink, 3 are green and 3 are yellow. Counters are removed at
random, one at a time and without replacement. Find the probability that
(a) The first one drawn is green
(b) The first two drawn are of the same colour
(c) The first three drawn are of different colours
(d) The second one drawn is green, given that the first one drawn is pink
(e) The third one drawn is green, given that the first two are the same colour as each other.
Solution
Let P, G and Y be the corresponding events that ‘ pink, green and yellow counter is drawn’
The outcomes of the events are shown on the tree diagram that follows.
4 2⁄ G
8
10
Y
P 3⁄
8
4⁄
9
3
4⁄
8
P
2⁄
10 9 1⁄
G G 8
G
3⁄
3⁄ 8 Y
9 Y 4⁄
8
P
2⁄
3 8
10 2⁄
G
8
P
4⁄
Y
9
3⁄
9
Y G
2⁄ Y
9
The occurrence of three counters in different can be of 6 different ways as PGY, GPY, GYP, YPG,
PYG, and YGP.
The probability of any of these possibilities is the same with minor difference of arrangement of
numbers for which does not affect the numerical value since it is the product of the three numbers hence
the sum of the six products, can easily be calculated by multiplication of the single product by six
4×3×3 3
Thus probability of first three drawn counter of different colours = 6(10×9×8) = 10.
𝑃(𝑆⁄𝐺) × 𝑃(𝐺)
𝑃(𝐺 ⁄𝑆) =
𝑃(𝑆)
Since Bayes’ formula reverse the conditional probability as discussed earlier in this handout thus
P(S/G) is read as ‘the probability that the last two counters are of the same colour, given that the first on
drawn is green’ and can be calculated as
From the tree diagram, the last two counters of the same colour given the first is green
3
And P(G) = 10
P(S) is the probability of the first two counters drawn were of the same colour which can be either PP, GG,
and YY
4 3 3 2 3 2 4
P(S) = 10 × 10 + 10 × 10 + 10 × 10 = 15
The probability that the third counter drawn is green, given the first two are the same colour as each
5
other is 16
9. On a given a petrol station serves three times as many men as women. Two types of petrol are
available, grade A and grade B. Customers pay by cheque or by cash. 70% of the men and 40% of the
women buy grade A petrol. Of the men buying grade A petrol, 80% pay by cheque, and of the men
buying grade B petrol, 60% pay by cheque. Of the women buying grade A petrol, half pay by cheque
and of the women buying grade B petrol, 40% pay by cheque. Find the probability that
(a) A customer buys grade A petrol.
(b) A customer pays by cheque.
Let x be the probability that the women customer access the service at the petrol station
Since the petrol serves men 3 times as many as women, the probability that men access service at this petrol
station will be 3x
1
Then, the probability always sums to 1 i.e x + 3x = 1 for which x =
4
3 1
Now the probability of men and women to access the service at this petrol station are 𝑎𝑛𝑑 respectively.
4 4
Let M and W be the corresponding events that ‘men and women access the service at the petrol station
0.2 C
Customer A
0.8 C’
0.7
0.4 C
P(M)= 3⁄4
0.3 B
0.6 C’
C
0.5
A
0.4 0.5 C’
P(W)= 1⁄4
C
0.6
0.6
B
0.4 C’
2⁄ R
Bag 9
A
7⁄
9 G
1⁄
2
R
4⁄
1⁄ 5
2
B
1⁄ G
5
Marble colour
23
= 45
23
The probability that a red marble is drawn in a single trial = 45
.
(b) Given that a red marble is selected, the probability that when a coin is tossed and head is obtained
means the red marble is drawn from bag A
𝑃(𝑅 ⁄𝐴)×𝑃(𝐴)
From Bayes’ formula 𝑃(𝐴⁄𝑅) = 𝑃(𝑅)
4⁄ ×1⁄ 18
5 2
= 23⁄ = 25
45
23
The probability that head was obtained given that the red marble was selected is 45
11.
Age group Percentage
0-18 25
17-25 14
26-64 43
65 and over 18
In a town the percentage of males in particular age group are as shown in the table above. In a survey it
is found that the probability that a male aged 65 or over wearing glasses is 0.8. Similarly if a male is in
the age groups 0-16, 17-25, and 26-64 the probability of his wearing glasses are 0.2, 0.1, and 0.4
respectively. Given that a particular male is wearing glasses, use Bayes’ formula
𝑃(𝐴𝑘 )𝑃(𝐵/𝐴𝑘 )
P(Ak /B) = ∑𝑛 𝑃(𝐴𝑟 )𝑃(𝐵/𝐴𝑟 )
𝑟=1
to calculate the probability that is 65 or over . Similarly calculate the probabilities that he is in each
of the other age groups and hence state which age group is most likely to be in.
Solution
From the given Bayes’ formula Ak represent age group let k = 1, 2, 3 and 4 for corresponding age group
0-18, 17-25, 26-64 and 65 or over.
B represent the event that ‘a male wears glasses’
The outcomes are shown by an asterisk on the tree diagram below
Glasses
Age group
P(B/A1) = 0.2
*P(B/A1) P(A1) = 0.2×0.25
P(A1) = 0.25
P(A3) = 0.43
P(B/A3) = 0.4 *P(B/A3) P(A3) = 0.4×0.43
P(A4) = 0.18
P(B/A4) = 0.8 *P(B/A4) P(A4) = 0.8×0.18
P(X) = 1⁄6
P(D/Y) = 0.015
*P(D/Y)P(Y) = 0.015×1⁄3
P(Y) = 1⁄3
P(Z) = 1⁄
2 P(D/Z) = 0.02 *P(D/Z)P(Z) = 0.02×1⁄2
Belts
0.01×1⁄6
= 0.01×1⁄ +0.015×1⁄ +0.02×1⁄
6 3 2
1
=10
1
The probability that the defective belt has been produced by machine X is .
10
2 3 1
13. A and B are two events for which P(A) = , P(B’/A) = and P(B/A’) = .
5 4 3
(a) Draw a fully labeled tree diagram with A preceding B, that is with A and A’ on the first two
branches
(b) Calculate
(i) P(A∩B)
(ii)P(A’∩B)
(iii) P(A∪ 𝐵)
(c) Calculate
(i) P(A|B)
(ii) P(A’|B’)
(d) Use your answers to (c) to draw a fully labeled tree diagram with B preceding A.
Solution
(a) P(B|A) =
1
1 2
4 *P(B|A)P(A) = ×
4 5
2
P(A) = 3 3 2
5 P(B’|A) = *P(B’|A)P(A) = ×
4 4 5
1 1 3
P(B|A’) = *P(B|A’)P(A’) = ×
3 3 5
3
P(A’) =
5
2 3
2 *P(B’|A’)P(A’) = ×
P(B’|A’) = 3 5
3
(b)
(i) P(A∩B) = P(A) ×P(B)
From the tree diagram
2 1 1
P(A∩B) = 5 × 4 = 10
(ii) P(A’∩B) = P(A’) × P( B)
3 1 1
=5×3=5
3
P(B) =
10
2 2 3
P(A’ |B) = *P(A’|B)P(B) = ×
3 3 10
3
P(A| B’) = 3 7
7
7 *P(A|B’)P(B’) = ×
P(B’) = 7 10
10
4 7
4
*P(A’|B’)P(B’) = ×
7 10
P(A’| B’) =
7
NOTE: To check the correctness of the probability distribution, the sum off all outcomes
must be 1
1 3 2 3 3 7 4 7
In above tree diagram, the sum of all outcomes = 3
×
10
+ ×
3 10
+ ×
7 10
+ ×
7 10
10
= =1
10
A’
(i) By considering the diagram which represent the sample space S, for A∪A’, where B is an abitrary
𝑃(𝐴)𝑃(𝐵|𝐴)
event of S such that P(B) ≠ 0, show that P(A|B) = 𝑃(𝐴)𝑃(𝐵 |𝐴)+𝑃(𝐴′ )𝑃(𝐵|𝐴′ )
(ii)The probabilities that a boy goes to school by bus, bicycle or on foot on a certain day are 0.2, 0.3 and
0.5 respectively. The probability of his being late by these methods are 0.6, 0.3 and 0.1 respectively.
If he was late on this particular day, using Bayes’ theorem or otherwise, calculate the probability that
he travelled by bus.
Solution
(i) From conditional probability
𝑃(𝐴 ⋂ 𝐵) 𝑃(𝐴∩𝐵)
P(𝐴⁄𝐵 ) = and P(𝐵⁄𝐴) =
𝑃(𝐵) 𝑃(𝐴)
For which 𝑃(𝐴 ∩ 𝐵) = 𝑃(𝐴 ∩ 𝐵) 𝑜𝑟 𝑃(𝐴⁄𝐵) × 𝑃(𝐵) = 𝑃(𝐵⁄𝐴) × 𝑃(𝐴)
Making P(A/B) subject of the formula
𝑃(𝐵⁄𝐴) × 𝑃(𝐴)
𝑃(𝐴⁄𝐵) =
𝑃 (𝐵)
𝑃(𝐵⁄𝐴) × 𝑃(𝐴)
𝑃(𝐴⁄𝐵) =
𝑃 (𝐵)
(ii) Let A, B and C be the event that ‘the boy goes to school by bus, bicycle or foot’
D be the event that ‘he is being late’
The outcomes are shown with an asterisk on tree diagram that follows.
P(A)= 0.2
P(D|B)= 0.3
P(B)= 0.3 *P(D|B)P(B)= 0.3×0.3
P(C)= 0.5
P(D|C)= 0.1 *P(D|C)P(C)= 0.1×0.5
𝑃(𝐴1 )𝑃(𝐵|𝐴1)
Making P(A1|B) subject of the formula give the expression P(A1|B) = but P(B)= ∑31 𝑃 (𝐴𝑟 )𝑃(𝐵|𝐴𝑟 )
𝑃(𝐵)
𝑃(𝐴 )𝑃(𝐵|𝐴1 )
Therefore, P(A1|B) = ∑3 𝑃(𝐴1 hence shown.
1 𝑟 )𝑃(𝐵|𝐴𝑟 )
P(A1)= 0.35
P(B|A2)= 0.01
P(A2)= 0.45 *P(B|A2)P(A2)= 0.01×0.45
P(A3)= 0.2
P(B|A3)= 0.03 *P(B|A3)P(A3)= 0.03×0.2
1 𝑃(𝐴 )𝑃(𝐵|𝐴1)
P(A1|B) = ∑3 𝑃(𝐴
1 𝑟)𝑃(𝐵|𝐴𝑟)
0.02×0.35 2
= 7⁄ =5
400
= 0.4
2 𝑃(𝐴 )𝑃(𝐵|𝐴2)
P(A2|B) = ∑3 𝑃(𝐴
1 𝑟)𝑃(𝐵|𝐴𝑟 )
0.01×0.45 9
= 7⁄ = 35
400
= 0.257 (3 d.p)
3 𝑃(𝐴 )𝑃(𝐵|𝐴3)
P(A3|B) = ∑3 𝑃(𝐴
1 𝑟)𝑃(𝐵|𝐴𝑟 )
0.03×0.2 12
= 7⁄ =
400 35
= 0.343 (3 d.p )