Law of total probability

In probability theory, the law (or formula) of total probability is a fundamental rule relating marginal probabilities to conditional probabilities. It expresses the total probability of an outcome which can be realized via several distinct events, hence the name.

Statement
The law of total probability is a theorem that states, in its discrete case, if $$\left\{{B_n : n = 1, 2, 3, \ldots}\right\}$$ is a finite or countably infinite set of mutually exclusive and collectively exhaustive events, then for any event $$A$$:


 * $$P(A)=\sum_n P(A\cap B_n)$$

or, alternatively,


 * $$P(A)=\sum_n P(A\mid B_n)P(B_n),$$

where, for any $$n$$, if $$P(B_n) = 0 $$, then these terms are simply omitted from the summation since $$P(A\mid B_n)$$ is finite.

The summation can be interpreted as a weighted average, and consequently the marginal probability, $$P(A)$$, is sometimes called "average probability"; "overall probability" is sometimes used in less formal writings.

The law of total probability can also be stated for conditional probabilities:


 * $$P( {A|C} ) = \frac = \frac = \frac = \sum\limits_n P ( {A\mid {B_n},C} )P( {{B_n}\mid C} )$$

Taking the $$B_n$$ as above, and assuming $$C$$ is an event independent of any of the $$B_n$$:


 * $$P(A \mid C) = \sum_n P(A \mid C,B_n) P(B_n) $$

Continuous case
The law of total probability extends to the case of conditioning on events generated by continuous random variables. Let $$(\Omega, \mathcal{F}, P) $$ be a probability space. Suppose $$ X $$ is a random variable with distribution function $$F_X$$, and $$A$$ an event on $$(\Omega, \mathcal{F}, P) $$. Then the law of total probability states

$$P(A) = \int_{-\infty}^\infty P(A |X = x) d F_X(x). $$

If $$X$$ admits a density function $$f_X$$, then the result is

$$P(A) = \int_{-\infty}^\infty P(A |X = x) f_X(x) dx. $$

Moreover, for the specific case where $$A = \{Y \in B \}$$, where $$B$$ is a Borel set, then this yields

$$P(Y \in B) = \int_{-\infty}^\infty P(Y \in B |X = x) f_X(x) dx. $$

Example
Suppose that two factories supply light bulbs to the market. Factory X ' s bulbs work for over 5000 hours in 99% of cases, whereas factory Y ' s bulbs work for over 5000 hours in 95% of cases. It is known that factory X supplies 60% of the total bulbs available and Y supplies 40% of the total bulbs available. What is the chance that a purchased bulb will work for longer than 5000 hours?

Applying the law of total probability, we have:



\begin{align} P(A) & = P(A\mid B_X) \cdot P(B_X) + P(A\mid B_Y) \cdot P(B_Y) \\[4pt] & = {99 \over 100} \cdot {6 \over 10} + {95 \over 100} \cdot {4 \over 10} = {{594 + 380} \over 1000} = {974 \over 1000} \end{align} $$

where
 * $$P(B_X)={6 \over 10}$$ is the probability that the purchased bulb was manufactured by factory X;
 * $$P(B_Y)={4 \over 10}$$ is the probability that the purchased bulb was manufactured by factory Y;
 * $$P(A\mid B_X)={99 \over 100}$$ is the probability that a bulb manufactured by X will work for over 5000 hours;
 * $$P(A\mid B_Y)={95 \over 100}$$ is the probability that a bulb manufactured by Y will work for over 5000 hours.

Thus each purchased light bulb has a 97.4% chance to work for more than 5000 hours.

Other names
The term law of total probability is sometimes taken to mean the law of alternatives, which is a special case of the law of total probability applying to discrete random variables. One author uses the terminology of the "Rule of Average Conditional Probabilities", while another refers to it as the "continuous law of alternatives" in the continuous case. This result is given by Grimmett and Welsh as the partition theorem, a name that they also give to the related law of total expectation.