NewTurn any lesson into a live trading bot with one prompt, using AgenKitagenkit.xyz

Part 1 · ProbabilityLesson 414 minQuant Bible §2.3

The seven distributions you must know

Bernoulli, binomial, Poisson, geometric, uniform, normal and exponential: shape, mean, variance and where each one shows up.

Most interview problems are a familiar distribution in disguise. Recognise it, and the mean and variance come for free. Here are the seven to know cold, with what each one counts and where it shows up on a desk.

Discrete: counting things

VariableWhat it countsPMFMeanVariance
Bernoulli(p)(p)one yes/no trialpx(1−p)1−xp^x(1-p)^{1-x}ppp(1−p)p(1-p)
Binomial(n,p)(n,p)successes in nn trials(nx)px(1−p)n−x\binom{n}{x}p^x(1-p)^{n-x}npnpnp(1−p)np(1-p)
Poisson(λ)(\lambda)events in a fixed windowλxe−λx!\dfrac{\lambda^x e^{-\lambda}}{x!}λ\lambdaλ\lambda
Geometric(p)(p)trials until first success(1−p)x−1p(1-p)^{x-1}p1/p1/p(1−p)/p2(1-p)/p^2

Continuous: measuring things

VariableWhat it measuresPDFMeanVariance
Uniform(a,b)(a,b)a value equally likely anywhere in [a,b][a,b]1b−a\dfrac{1}{b-a}a+b2\dfrac{a+b}{2}(b−a)212\dfrac{(b-a)^2}{12}
Normal(μ,σ2)(\mu,\sigma^2)sums and averages of many small effects1σ2πe−12(x−μσ)2\dfrac{1}{\sigma\sqrt{2\pi}}e^{-\frac12\left(\frac{x-\mu}{\sigma}\right)^2}μ\muσ2\sigma^2
Exponential(λ)(\lambda)waiting time for the next Poisson eventλe−λx\lambda e^{-\lambda x}1/λ1/\lambda1/λ21/\lambda^2

For a continuous variable, probabilities come from the cumulative distribution function, F(a)=P(X≤a)=∫−∞af(x) dxF(a) = P(X \le a) = \int_{-\infty}^{a} f(x)\,dx. The density is not itself a probability; areas under it are.

Figure 4.1Distribution explorer, in 3D
Discrete distributions stand as columns of probability; continuous ones are a solid ribbon whose area is 1. The green plane marks the mean and the shaded strip is ±1σ. Rotate to read the shape from any side.
Figure 4.2The same, with the cumulative view
Pick a distribution and move its parameters. The green line is the mean and the shaded band is ±1σ. For the binomial, turn on the Poisson overlay and push n up while keeping np small: the two collapse onto each other.

How they connect

  • Binomial → Poisson. With nn huge and pp tiny so that np=λnp = \lambda stays fixed, the binomial becomes Poisson(λ)(\lambda). Rare events in a big population (defaults in a loan book, large orders in a second) are Poisson.
  • Poisson ↔ exponential. If events arrive as a Poisson process with rate λ\lambda, the gaps between them are exponential with mean 1/λ1/\lambda. Counts and waiting times are two views of the same process.
  • Memorylessness. The geometric and exponential are the only memoryless distributions: P(X>s+t∣X>s)=P(X>t)P(X > s + t \mid X > s) = P(X > t). If you’ve waited 5 minutes for a trade, the expected further wait is unchanged.
  • Sums → normal. Add up many independent pieces and you approach a normal distribution, whatever the pieces look like. That is the central limit theorem, in lesson 6.

Functions of a random variable

If you know the distribution of XX and Y=g(X)Y = g(X) with gg strictly increasing, then FY(a)=P(g(X)≤a)=FX(g−1(a))F_Y(a) = P(g(X)\le a) = F_X\big(g^{-1}(a)\big); differentiate for the density. Example: if XX is normal, Y=eXY = e^X is lognormal, the standard model for prices that can’t go negative (and for house sizes in lesson 14).

In code

from scipy import stats

print(stats.binom(n=20, p=0.3).mean(), stats.binom(n=20, p=0.3).var())  # 6.0 4.2
print(stats.poisson(mu=4).pmf(2))                     # P(exactly 2 events) ≈ 0.147
print(stats.geom(p=0.2).mean())                       # 5 trials on average
print(stats.expon(scale=1 / 2).cdf(1))                # P(wait < 1) at rate 2 ≈ 0.865
print(stats.norm(0, 1).ppf(0.975))                    # 1.96, the 95% two-sided z-score

# Binomial -> Poisson: n = 1000, p = 0.004 against Poisson(4)
print(stats.binom(1000, 0.004).pmf(3), stats.poisson(4).pmf(3))

Check yourself

Trades print as a Poisson process at 3 per minute. You have already waited 40 seconds without a trade. What is the expected additional wait?

Progress is saved in this browser only.