Probability of a Defective Product — the Law of Total Probability

Problem. A certain product is made by two factories a and b. Suppose 18% of the products of factory a and 12% of the products of factory b are defective. The products of the two factories are mixed in the ratio a : b = 4 : 6 into a very large batch, and one product is drawn at random from it. What is the probability that it is defective?

Move the parameters

Let A be the event that the product is from factory a, B the event that it is from factory b, and C the event that it is defective; compute P(C) using A and B.
P(A) = 0.40, P(B) = 0.60

Area diagram — probabilities as areas

factory a, good factory a, defective P(AC) factory b, good factory b, defective P(BC)
Column widths are the mixing proportions P(A), P(B); the heights of the dark bands are the defect rates. The total area of the two dark rectangles is P(C).

Computation — the law of total probability

0.144 = probability that the drawn product is defective, P(C)

Extension (Bayes' theorem): given that the product is defective, which factory did it come from?

Simulation — check it by actually drawing products

0 products drawn
gooddefectivetotal
factory a000
factory b000
total000
Observed fraction of defectives
Theoretical value P(C)
0.144
Origin of the defective draws (observed) → P(A|C), P(B|C)
Theoretical values (Bayes' theorem)

Back to Collection