Discrete Mathematics for Computer Science

(Romina) #1
Independent Events and Conditional Probability 513

Example 4. There are three kinds of vending machines in canteens at the university:
candy dispensers, hot-drink dispensers, and soda dispensers. Of the vending machines,
25% sell candy, 35% dispense hot drinks, and 40% dispense sodas. Suppose that servic-
ing is needed by 1/2 the candy machines, 1/5 the hot drink machines, and 1/3 the soda
machines. What is the probability that a machine chosen at random needs servicing?

Solution. Let Q consist of all the machines, and endow 02 with a uniform probability
density to model choosing a machine at random. Let El, E 2 , and E 3 denote the candy, hot-
drink, and soda machines, respectively. Then, Q2 is the disjoint union of these events where

P(E 1 ) = 0.25, P(E 2 ) = 0.35, and P(E 3 ) = 0.40. Let A denote the set of nonfunctioning

machines. Event A is the disjoint union of the nonfunctioning candy, hot-drink, and soda
machines, and
1 1 1
P(A I E)=- P(A I E 2 )=- P(A I E 3 )=-
2 5 3
By the Total Probability Theorem,
3
P(A) =E P(A I Ei) .P(Ei)
i=1

().25)+ (.35 ()(0.40)

0.328 U

Now, we give the other result, Bayes' Rule, that can be obtained by playing with the
expression in the definition of conditional probability. We began by noticing that

P(B n A) = P(A) .P(B I A)

To warm up for Bayes' Rule, notice that interchanging the roles of A and B gives another

expression for P (B n A)-namely,

P(A n B) = P(B) • P(A [ B)

Theorem 2. (Bayes' Rule) Let A and B be events in the same sample space. If neither

P(A) nor P(B) is zero, then

P(B I A) = P(A I B)-(B)

PABP (A)

Proof. By the definition of conditional probability,

P(A nl B) P(I)P(A nB)


P(A I B) (A- P(B) B and P (B I A)= (A- P(A)B

Consequently,

P(A n B) = P(A) .P(B I A) = P(B) .P(A I B)

so

P(B I A) = P(A I B) P(B) P((A) M
Free download pdf