Conditional probability
Knowing that B happened shrinks the world to the cases where B is true. The conditional probability of A is the share of those cases where A happens too.
01The formula
- the chance of A once you know B has happened, read 'A given B'
- the chance that A and B both happen
- the chance of B, the thing you already know
02See it move
03Where it is used
- Quant researcherMeasures how often a stock rises on days the market rises, or how often a signal works in a given regime, instead of averaging over all days.
- Risk managerAsks what the chance of a big loss is given that volatility is already high, which is usually far larger than the unconditional chance.
- Retail traderChecks whether a pattern still wins once you condition on the setup actually appearing, not on every day in the sample.
04Why traders use it
Almost every trading question is conditional: given this signal, this news, this regime, what happens next? Using the unconditional chance when you have extra information throws that information away.
05Worked example
The market rises on 55% of days, and both the market and the stock rise on 33% of days. Given an up day for the market, the stock rises 60.0% of the time, against 48.0% over all days and only 33.3% on down days for the market.
06How it is built
- Count only the cases where happened. Their share of everything is .
- Among those, count the cases where happened too. Their share of everything is .
- The share of -cases that are also -cases is the ratio: .
- Rearranged, it gives the multiplication rule: .
07The common mistake
Swapping the two sides. and are different numbers: the chance the market rose given the stock rose is not the chance the stock rose given the market rose. Turning one into the other needs Bayes' theorem.
08In Python and LaTeX
p_B, p_AB, p_AnotB = 0.55, 0.33, 0.15
print('P(A|B) =', round(p_AB / p_B, 3)) # 0.6
print('P(A) =', round(p_AB + p_AnotB, 3)) # 0.48
print('P(A|not B) =', round(p_AnotB / (1 - p_B), 3)) # 0.333P(A \mid B) = \frac{P(A \cap B)}{P(B)}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.