Bernoulli distribution
The simplest random variable: one trial with two outcomes, win or lose, coded 1 and 0. Its average is the win chance p.
01The formula
- the outcome of one trial: 1 for a win, 0 for a loss
- the chance of a win
- the chance of a loss
- the expected value, the long-run average of X
- the variance: how spread out the outcome is
02See it move
03Where it is used
- Quant researcherModels whether a signal's next trade wins or loses, before adding up many trades.
- Execution traderTreats each passive order as filled or not filled, with a fill chance p.
- Risk managerCounts breaches of a limit or a value-at-risk level as a series of yes-or-no events.
04Why traders use it
Every win rate, fill rate and hit ratio is a Bernoulli p. The binomial, geometric and many other distributions are just Bernoulli trials repeated.
05Worked example
A strategy wins 55% of its trades. Coded as 1 or 0, one trade has mean 0.55 and variance 0.2475, a standard deviation of 0.497. Over 100 trades a day you expect about 55.0 winners.
06How it is built
- List the two outcomes: with chance , with chance .
- Mean: .
- Since when X is 0 or 1, .
- Variance: , largest at .
07The common mistake
Reading a high win rate as a good strategy. The Bernoulli only says how often you win, not how much; a 90% win rate with tiny wins and huge losses still loses money.
08In Python and LaTeX
from scipy.stats import bernoulli p = 0.55 print(bernoulli.mean(p), round(bernoulli.var(p), 4)) # 0.55 0.2475
P(X = 1) = p,\quad P(X = 0) = 1 - p,\qquad E[X] = p,\quad \operatorname{Var}(X) = p(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 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.