The Claude Quant PlaybookDownload ebookDownload ebook

Conditional probability

beginnerProbability1 of 12

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.

Build a trading system with Claude.Download ebook

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

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

  1. Count only the cases where happened. Their share of everything is .
  2. Among those, count the cases where happened too. Their share of everything is .
  3. The share of -cases that are also -cases is the ratio: .
  4. 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.333
P(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 AgenKit

The worked example and the model run the same code, so every number matches. Models simplify markets on purpose. This is education, not financial advice.