Law of total probability
Split the world into scenarios, find the chance of the event inside each one, and add them up weighted by how likely each scenario is. The result is the overall chance of the event.
01The formula
- the event you care about, here: a losing day
- scenarios that do not overlap and cover every case, here: calm days and stressed days
- the chance of A inside scenario i
- how likely scenario i is
02See it move
03Where it is used
- Risk managerBuilds a loss probability from regimes: calm, normal and stressed markets, each with its own chance of a large loss.
- Portfolio managerWeighs the outcome of a position across scenarios such as a rate hike, a hold or a cut, using the market's probabilities for each.
- Options deskPrices event risk by mixing the move distribution with and without the event, weighted by its chance.
04Why traders use it
It is often easier to say what happens in each scenario than to say what happens overall. This formula lets you build the overall chance from simple pieces, and it is the denominator of Bayes' theorem.
05Worked example
If 20% of days are stressed, a strategy loses on 40% of calm days and 70% of stressed days. Overall it loses on 46.0% of days: 32.0% from calm days plus 14.0% from stressed ones.
06How it is built
- The scenarios do not overlap and together cover everything, so splits into the pieces .
- So .
- Each piece is by the multiplication rule.
- Substitute to get .
07The common mistake
Using scenarios that overlap or leave gaps. If a day can be both calm and stressed, or neither, the weights no longer add up to 1 and the total is wrong.
08In Python and LaTeX
p_stress = 0.20 loss_calm, loss_stress = 0.40, 0.70 p_loss = (1 - p_stress) * loss_calm + p_stress * loss_stress print(round(p_loss, 4)) # 0.46
P(A) = \sum_i P(A \mid B_i)\,P(B_i)
09Where it fits
Rather not code the maths yourself? Describe your trading idea and let AI build the bot.
Build a bot with AgenKitThe worked example and the model run the same code, so every number matches. Models simplify markets on purpose. This is education, not financial advice.