The Claude Quant PlaybookDownload ebookDownload ebook

Geometric distribution

intermediateDistributions3 of 11

How many attempts you need until the first success, when each attempt succeeds with the same chance p. Short waits are most likely, but long ones keep happening.

Build a trading system with Claude.Download ebook

01The formula

the attempt on which the first success happens
a particular attempt number: 1, 2, 3, …
the chance each attempt succeeds
the chance the first k − 1 attempts all fail

02See it move

03Where it is used

04Why traders use it

It gives the odds on waiting. Traders who expect the next success soon after a run of failures are wrong: the chance is the same p every attempt.

05Worked example

Each attempt succeeds with chance 20%. The chance the first success comes on attempt 5 is 8.19%, and the chance you succeed within 5 attempts is 67.2%. On average you need 5.00 attempts.

06How it is built

  1. For the first success to land on attempt , the first attempts must fail and attempt must succeed.
  2. By independence that has probability .
  3. The chance of no success in attempts is , so .
  4. Summing over all gives the mean .

07The common mistake

Believing a success is 'due'. The geometric distribution is memoryless: after ten failures the chance of needing more than five further attempts is the same as it was at the start.

08In Python and LaTeX

from scipy.stats import geom
p, k = 0.2, 5
print(round(geom.pmf(k, p), 4), round(geom.cdf(k, p), 4), geom.mean(p))
P(X = k) = (1 - p)^{k - 1} p, \qquad P(X \le k) = 1 - (1 - p)^k, \qquad E[X] = \frac{1}{p}

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.