# Law of Total Probability: Definition & Examples

In probability theory, the law of total probability is a useful way to find the probability of some event A when we don’t directly know the probability of A but we do know that events B1, B2, B3… form a partition of the sample space S.

This law states the following:

The Law of Total Probability

If B1, B2, B3… form a partition of the sample space S, then we can calculate the probability of event A as:

P(A) = ΣP(A|Bi)*P(Bi)

The easiest way to understand this law is with a simple example.

Suppose there are two bags in a box, which contain the following marbles:

• Bag 1: 7 red marbles and 3 green marbles
• Bag 2: 2 red marbles and 8 green marbles

If we randomly select one of the bags and then randomly select one marble from that bag, what is the probability that it’s a green marble?

In this example, let P(G) = probability of choosing a green marble. This is the probability that we’re interested in, but we can’t compute it directly.

Instead we need to use the conditional probability of G, given some events B where the Bi‘s form a partition of the sample space S. In this example, we have the following conditional probabilities:

• P(G|B1) = 3/10 = 0.3
• P(G|B2) = 8/10 = 0.8

Thus, using the law of total probability we can calculate the probability of choosing a green marble as:

• P(G) = ΣP(G|Bi)*P(Bi)
• P(G) = P(G|B1)*P(B1) + P(G|B2)*P(B2)
• P(G) = (0.3)*(0.5) + (0.8)*(0.5)
• P(G) = 0.55

If we randomly select one of the bags and then randomly select one marble from that bag, the probability we choose a green marble is 0.55.

Read through the next two examples to solidify your understanding of the law of total probability.

### Example 1: Widgets

Company A supplies 80% of widgets for a car shop and only 1% of their widgets turn out to be defective. Company B supplies the remaining 20% of widgets for the car shop and 3% of their widgets turn out to be defective. If a customer randomly purchases a widget from the car shop, what is the probability that it will be defective?

If we let P(D) = the probability of a widget being defective and P(Bi) be the probability that the widget came from one of the companies, then we can compute the probability of buying a defective widget as:

• P(D) = ΣP(D|Bi)*P(Bi)
• P(D) = P(D|B1)*P(B1) + P(D|B2)*P(B2)
• P(D) = (0.01)*(0.80) + (0.03)*(0.20)
• P(D) = 0.014

If we randomly buy a widget from this car shop, the probability that it will be defective is 0.014.

### Example 2: Forests

Forest A occupies 50% of the total land in a certain park and 20% of the plants in this forest are poisonous. Forest B occupies 30% of the total land and 40% of the plants in it are poisonous. Forest C occupies the remaining 20% of the land and 70% of the plants in it are poisonous. If we randomly enter this park and pick a plant from the ground, what is the probability that it will be poisonous?

If we let P(P) = the probability of the plant being poisonous, and P(Bi) be the probability that we’ve entered one of the three forests, then we can compute the probability of a randomly chosen plant being poisonous as:

• P(P) = ΣP(P|Bi)*P(Bi)
• P(P) = P(P|B1)*P(B1) + P(P|B2)*P(B2) + P(P|B3)*P(B3)
• P(P) = (0.20)*(0.50) + (0.40)*(0.30) + (0.70)*(0.20)
• P(P) = 0.36

If we randomly pick a plant from the ground, the probability that it will be poisonous is 0.36.