# IB Class Notes

## Conditional Probability

Aims: By the end of this note, you will be able to

1. state the concept of conditional probability;
2. employ the formula for conditional probability &
3. use appropriate tree diagram to solve problems for conditional probability.

Bayes Theorem is in the HL syllabus and an extension for SL.

Conditional Probability

### Defining a Conditional Probability

1. In a math class there are 8 female students and 7 male students. A student is going to be selected at random from this class to work out a problem on the board.
1. What is the probability that a male student is selected?
The answer here is pretty obvious and it is simply 7 out of 15 or 7/15.

Let us assume that John is in this math class.

2. What is the probabibility that John is selected given that you know a male student has already been picked?
This is a conditional probability because we are asked to work out the probability of, say event A, conditioned upon something else, say event B that has already occured. For our problem above, the sample size basically shrunk from the whole class to that of male student body in the class. John is one of the 7 male students. Thus, the answer is 1/7.

Conditional Probability
If A and B are two events then the conditional probability of event A given event B is expressed as $\large P(A|B) = \frac{P \left( A \cap B \right) }{P \left( B \right)}, \space \space P \left( B \right) \ne 0$

2. If A and B are mutually exclusive then P(A|B) = 0.
This should be obvious. Let us get an insight using our previous example. Let us ask this question,
"What is the probability that John (a male) is selected given that we know a female student has been picked?"
In symbol the question is P(John|female) = 0 because John is not a female thus John is selected will be nil if we already knew that a female is picked.

3. The multiplication rule applies:
P(A ∩ B) = P(A|B) x P(B)
----------------(2)
From the definition of conditional probability above we should expect that usually P(A|B) ≠ P(B|A).

If event A and event B are independent then
P(A ∩ B) = P(A)P(B)
If event A and event B are independent then P(A|B)=P(A).
What it says is that since A and B are independent the outcome of A is not affected by whether or not event B occurs.

 P(A|B) = P(A ∩ B)     P(B) , P(B) ≠ 0 P(A|B) = P(A)P(B)   P(B) , P(B) ≠ 0 P(A|B) = P(A)
4. Example 1.
According to a weather forecaster, the probability that the next day is windy is 0.70 and the probability that the next day is sunny is 0.80. The probability that the next day is both windy and sunny is 0.60. Let W and S be windy and sunny conditions respectively.
Find
1. P(W|S)
2. P(S|W)
3. P(W ' |S)
Solutions:
We are given P(W)=0.70, P(S)=0.80 and P(W ∩ S) = 0.60.
1. P(W|S) = P(W ∩ S) / P(S) from the definition of conditional probability.
P(W|S) = 0.60 / 0.80
P(W|S) = 3/4.
2. P(S|W) = = P(W ∩ S) / P(W) ; note that P(W ∩ S) = P(S ∩ W)
P(S|W) = 0.60 / 0.70
P(S|W) = 6/7
3. P(W ' |S)= 1- P(W|S)
P(W ' |S)= 1- 3/4
P(W ' |S)= 1/4

 Example 2. Given that P(B|A) = 0.80 and P(A ∩ B) = 0.20. Find P(A). Solution: P(B|A) = P(A ∩ B) / P(A) P(A) = P(A ∩ B) / P(B|A) P(A) = 0.2 / 0.8 P(A) = 2/8. Example 3. Given that P(B) = 0.45 and P(A|B)=0.60. Find P(A ∩ B). Solution: P(A|B) = P(A ∩ B) / P(B) P(A ∩ B) = P(A|B)P(B) P(A ∩ B) = 0.60 x 0.45 P(A ∩ B) = 0.27

5. Most questions that you will find at this level does not really require you to use the above expression of conditional probability. You can use basic intuition like the solution to John above or tree diagrams to solve these questions.

6. Example 4.
A brown bag has 6 blue chocolate balls and 5 red chocolate balls. Eduardo picks a chocolate ball at random from the bag and eats it. He then eats another chocolate ball after picking it at random from the bag.
1. Draw a tree diagram to represent the process.
2. Find the probability that the second chocolate ball is red given that he ate a blue ball.
3. What is the probability that the first ball is blue given that he ate a second red ball? Solutions:
1. Here is the tree diagram. Here, the "1" in R1 and B1 represents the first pick and similarly "2" in R2 and B2 represents the second pick. Notice that all branches in the second pick represent conditional probabilities.
2. Basiclly we want to find P(R2|B1). The answer is in the tree diagram and it is 5/10. (third branch in the 2nd pick).
3. The question is P(B1|R2) and this is however cannot be read off directly from the tree diagram. The condition is blue in the second pick. So let us first identify all the blue in the second pick, blue paths in the second tree diagram So our "new sample space" is P(R2) = (5/11)(4/10) + (6/10)(5/10)
P(B) = 50/110.
Out of these two paths, the bottom one is the one we want; P(B1∩R2)=(6/11)(5/10) =30/110. Thus
P(B1|B2) = [30/110] / [50/110]
P(B1|B2) = 3/5
7. Example 5.
In a cookie pot there are 12 chocolate chip cookies and 8 almond cookies and 1 butter cookie. Winnie the Pooh comes in a pick a cookie at random from the pot for Piglet who then eats it. Pooh then picks another cookie at random from the pot for himself.
1. Draw a tree diagram to represent this process.
2. Find the porbability that Pooh picks a butter cookie for himself given that Piglet ate an almond cookie?
3. What is the probability that Piglet eats an almond cookie given that Pooh picked an almond cookie for himself. Solutions:
1. In this tree diagram, A, B, and C stand for almond, butter and chocolate chip cookie respectively.
2. The question is to find P(B2|A1). This can be directly obtained from the diagram, branch 6 under Pooh. Answer is 1/20.
3. The question here is to find p(A1|A2). First is to identified the shrunk sample space, represented by the blue paths in the tree diagram. The "new sample space" is (12/21)(8/20)+(8/21)(7/20)+(1/21)(8/20) = 160 / 420.
The second path is the one that we want which is (8/21)(7/20). Thus,
P(A1|A2) = (8/21)(7/20) / (160/420)
P(A1|A2) = 56/160
P(A1|A2) = 7/20.

### Bayes' Thoerem

Question (c) in Example 5 above is basically an application of Bayes' Theorem which was developed by Rev. Thomas Bayes (1702-1761) that gives us a method of adjusting a set of associated probabilities when new information becomes available. We can think of this theorem as an extention of conditional probability in equation (1) above.

Let us consider the Venn diagram below. It is probably clear that part of A is in B and part of A is in B'. Thus,
P(A) = P(A ∩ B) + P(A ∩ B' ), using equation (2) we obtain
P(A) = P(B)P(A|B) + P(B)P(A|B' ) ----------------(3)  Equation (3) is known as the Law of Total Probability. Although equation (3) looks complicated, it is nothing more than an expression of the familiar tree diagram above. Thus, equation (3) is just the summation of the relevant branches in our tree diagram. In general, the problem does not have to be restricted to two events B and B'. Instead, we can have n events B1, B2, ..., Bn and the total probability of A becomes
P(A) = P(B1)P(A|B1) + P(B2)P(A|B2 ) + ...+ P(Bn)P(A|Bn ) ----------------(4) .

However, in IB, you will often not deal with questions more than 3 events of B. Now we are ready to describe the Bayes' Theorem which is basically rewriting of equation (1) by replacing numerator with equation (3) and the denominator with equation (4):

 P(B|A) = P(A ∩ B)     P(A) , P(A) ≠ 0 P(B|A) = P(B)P(A|B) P(B)P(A|B) + P(B')P(A|B') ------(5)

In equation (5), event A is often treated as new information and B as the old information. Basically, Bayes' Theorem allows us to update our probability for event B given new information. In the questions below, we will apply equation (5) explicitly although all of them can also be solved by tree diagrams.

Example 6: Given that P(A) = 0.4, P(B|A) = 0.03 and P(B|A') = 0.05. Calculate the following:
a) P(B),     (b) P(A'|B),     (c) P(B'|A)
Solutions:
(a) P(B) = P(A)P(B|A) + P(A')P(B|A'), and P(A') = 1-P(A) = 0.6
P(B) = 0.4(0.03)+0.6(0.05)
P(B) = 0.042

(b) P(A'|B) = P(A')P(B|A') / P(B)
P (A'|B) = 0.6(0.05) / 0.042
P (A'|B) = 0.714

(c)P(B'|A) = 1-P(B|A)
P(B'|A) = 1-0.03
P(B'|A) = 0.97

#### Exercises

1. Given that P(A)=0.7, P(B|A)=0.4 and P(B|A')=0.2. Calculate the following:
a) P(A'),     (b) P(B),     (c) P(A'|B)

2. Three machines A, B and C contribute 60%, 30%, and 10% respectively to the daily production of cellphone in a factory. Each machine also produces a total of 2%, 4% and 1% daily defective (event D) cellphones.
Let P(A), P(B), and P(C) stand for the probability a randomly selected cellphone is produced by machine A, B, and C respectively. P(D) represents the probability a randomly selected cellphone is defective. Calculate the following:

a) P(D|A),     (b) P(D|B),     (c) P(D)    (d) P(D'),     (e) P(B|D),     (f) P(C|D')