Sub topic 13
Conditional Probability, Independence and the Total Probability Rule
Prerequisites and scope
This chapter assumes you know what an event is and can use the addition rule, P(A or B) = P(A) + P(B) − P(A and B), and the basic multiplication rule. It also assumes you are comfortable with decimals and probabilities that sum to 1. It covers three connected tools: conditional probability, independence, and the total probability rule. The next chapter uses all three to build Bayes' formula.
Conditional probability
A conditional probability is the probability of an event given that another event has occurred. The notation P(A | B) reads "the probability of A given B". Knowing B happened shrinks the set of possible outcomes to B, so the probability is rescaled:
P(A | B) = P(A and B) / P(B), defined only when P(B) > 0.
Rearranging gives the multiplication rule for any two events:
P(A and B) = P(A | B) × P(B)
Suppose the economy expands with probability 0.60, and the probability that a stock rises and the economy expands is 0.42. Then P(stock rises | expansion) = 0.42 / 0.60 = 0.70. Among the cases where the economy expands, the stock rises 70% of the time.
The order matters. P(A | B) and P(B | A) are usually different numbers. They share the numerator P(A and B) but divide by different totals.
Independence
Two events are independent if knowing one occurred does not change the probability of the other:
P(A | B) = P(A), equivalently P(B | A) = P(B), equivalently P(A and B) = P(A) × P(B).
When events are independent, the multiplication rule reduces to a plain product. If two unrelated stocks each rise with probability 0.60 and their outcomes are independent, then:
- P(both rise) = 0.60 × 0.60 = 0.36
- P(at least one rises) = 0.60 + 0.60 − 0.36 = 0.84
To test independence from data, compare P(A and B) with P(A) × P(B). The code below uses a joint probability table for "stock rises" (A) and "index rises" (B).
p_a_and_b = 0.30 # stock up and index up
p_a = 0.30 + 0.10 # stock up (index up or down)
p_b = 0.30 + 0.20 # index up (stock up or down)
p_a_given_b = p_a_and_b / p_b
print(round(p_a_given_b, 4)) # 0.6
print(round(p_a, 4)) # 0.4
print(round(p_a * p_b, 4)) # 0.2
print(abs(p_a_and_b - p_a * p_b) < 1e-9) # False, so the events are dependentP(A | B) = 0.60 is larger than P(A) = 0.40, and the joint probability 0.30 differs from the product 0.20. The events are dependent, and a rising index makes a rising stock more likely.
Mutually exclusive is not independent
Mutually exclusive events cannot both occur, so P(A and B) = 0. If both events have positive probability, then P(A) × P(B) > 0, which does not equal 0. Mutually exclusive events with positive probabilities are therefore always dependent. If one occurs, the other is certain not to.
Conditional independence
Two events can be dependent overall but independent once you condition on a third event. For example, two firms' earnings may move together only because both depend on the economy. Given the state of the economy, they may be independent. This idea supports scenario-based analysis, where each scenario is treated separately.
The total probability rule
Often you know the probability of an event within each scenario, but not overall. Let B1, B2, ..., Bn be events that are mutually exclusive (no two can occur together) and exhaustive (together they cover every possibility). Then:
P(A) = P(A | B1) P(B1) + P(A | B2) P(B2) + ... + P(A | Bn) P(Bn)
This is a probability-weighted average of the conditional probabilities. Each term is a joint probability, P(A | Bi) P(Bi) = P(A and Bi), and the joint probabilities sum to P(A).
Worked example
An analyst models the economy in three states and estimates the chance that a company beats earnings forecasts in each.
| State | P(state) | P(beat given state) | Joint probability |
|---|---|---|---|
| Expansion | 0.50 | 0.80 | 0.40 |
| Normal | 0.30 | 0.50 | 0.15 |
| Recession | 0.20 | 0.10 | 0.02 |
The unconditional probability of a beat is 0.40 + 0.15 + 0.02 = 0.57.
The same calculation in code, with a check that the states form a valid partition:
scenarios = {
"expansion": (0.50, 0.80), # (P(state), P(beat | state))
"normal": (0.30, 0.50),
"recession": (0.20, 0.10),
}
assert abs(sum(p for p, _ in scenarios.values()) - 1.0) < 1e-9
p_beat = sum(p_state * p_beat_given for p_state, p_beat_given in scenarios.values())
print(round(p_beat, 4)) # 0.57The assert matters. The rule only works if the state probabilities sum to 1 and the states do not overlap.
Expected value version
The same idea applies to expected values. If E(X | Bi) is the expected value of X within scenario Bi, then:
E(X) = E(X | B1) P(B1) + ... + E(X | Bn) P(Bn)
This is how you combine scenario-specific expected returns into one overall expected return. The next chapters on expected value and portfolio return use the same weighting.
Common errors
| Error | Correction | Column | Column |
|---|---|---|---|
| Using P(B | A) when the question asks for P(A | B) | Identify which event is given. It goes after the bar and in the denominator. |
| Multiplying P(A) × P(B) for dependent events | Use P(A | B) × P(B) unless independence is stated or verified. | |
| Calling mutually exclusive events independent | If both have positive probability, they are dependent. | ||
| Weights that do not sum to 1 in the total probability rule | Check that the scenarios are exhaustive and exclusive. | ||
| Adding conditional probabilities directly | Weight each by its scenario probability first. |
Looking ahead
Suppose you learn that the company beat earnings. How likely is it that the economy was in expansion? That is P(expansion | beat) = 0.40 / 0.57, or about 0.70. It reverses the direction of conditioning, using the joint probability and the total probability as the denominator. This is exactly Bayes' formula, covered in the next chapter.
Exercise
The probability that interest rates rise is 0.40. If rates rise, the probability that a bond fund gains is 0.25. If rates do not rise, the probability that it gains is 0.65. What is the unconditional probability that the fund gains?
Show answer
The two rate outcomes are mutually exclusive and exhaustive, so use the total probability rule. P(gain) = 0.25 × 0.40 + 0.65 × 0.60 = 0.10 + 0.39 = 0.49.
Exercise
P(A) = 0.50, P(B) = 0.40 and P(A and B) = 0.20. Are A and B independent? Then compute P(A | B) and P(A or B).
Show answer
P(A) × P(B) = 0.50 × 0.40 = 0.20, which equals P(A and B), so the events are independent. P(A | B) = 0.20 / 0.40 = 0.50, which equals P(A). P(A or B) = 0.50 + 0.40 − 0.20 = 0.70.