Probability

Discrete Distributions

↩ Back
01

Bernoulli Distribution

Definition
A single yes or no trial

The Bernoulli distribution models one experiment with exactly two outcomes: success, coded as 1, with probability $p$, and failure, coded as 0, with probability $1-p$. Repeating it is what the rest of this page is about.

Probability mass function

$p_X(k) = \begin{cases} p & \text{if } k = 1 \\ 1-p & \text{if } k = 0 \end{cases}$

Parameters and support

p ∈ (0, 1) k ∈ {0, 1} 1 trial
Expectation and variance
Mean and spread of a single trial
Expectation
$E[X] = p$
The mean lands between the two outcomes, exactly at the success probability.
Variance
$\text{Var}(X) = p(1-p)$
Largest at $p = 0.5$, where the outcome is hardest to predict, and near zero at both extremes.

Where these come from

Directly from the definition: $E[X] = 1 \cdot p + 0 \cdot (1-p) = p$. Because a 0/1 variable satisfies $X^2 = X$, we also get $E[X^2] = p$, so $\text{Var}(X) = p - p^2 = p(1-p)$.

Example
Does a visitor click the ad?

A website shows an ad to one visitor. Past data says $8\%$ of visitors click it.

1
Identify the parameters: a single trial with $p = 0.08$
2
Apply the formula: $p_X(1) = 0.08$ for a click, and $p_X(0) = 1 - 0.08 = 0.92$ for no click
3
Read the mean: $E[X] = p = 0.08$ clicks per visitor, which is the click rate written as an expectation

Chaining many independent trials of this kind is exactly how the next distribution, the Binomial, gets built.

Interactive
Watch probability mass shift between the two outcomes

Move the slider to change $p$ and see how the mass shifts between the two possible outcomes, $0$ and $1$.

0.30
P(X = k)
Properties
Shape and connections

Shape of the PMF

Two bars and nothing else. Moving $p$ simply shifts mass from one bar to the other, and the two heights always add to $1$.


Sums of independent trials

Add up $n$ independent Bernoulli$(p)$ trials and the count of successes is Binomial.

$X_1 + X_2 + \cdots + X_n \sim \text{Binomial}(n, p)$

Link to the other distributions

Every distribution on this page is a different question asked about repeating this one trial: how many successes in a fixed batch, or how many attempts until a target number of successes.

Notation
Introduced in this section
SymbolMeaning
$X \sim \text{Bernoulli}(p)$a variable equal to 1 with probability $p$ and 0 otherwise
$p$probability of success on a single trial
$p_X(k)$probability mass function, that is $P(X = k)$
02

Binomial Distribution

Definition
Counting successes in n trials

Run $n$ independent Bernoulli$(p)$ trials and count the successes. That count $X$ follows a Binomial distribution. The combinatorial factor counts how many different orderings of successes and failures give the same total.

Probability mass function

$p_X(k) = \dbinom{n}{k} p^k (1-p)^{n-k}, \quad k = 0, 1, \dots, n$

Reminder · counting the orderings

$\dbinom{n}{k} = \dfrac{n!}{k!(n-k)!}$ is the number of ways to place $k$ successes among $n$ trial slots, one for every distinct ordering with the same total of successes.


Example, $n=4$ and $k=2$: the six orderings are SSFF, SFSF, SFFS, FSSF, FSFS, FFSS.

$\dbinom{4}{2} = \dfrac{4!}{2!\,2!} = \dfrac{24}{2 \times 2} = 6$

Parameters and support

n ∈ {1, 2, …} p ∈ (0, 1) k = 0, 1, …, n
Expectation and variance
Mean and spread of the success count
Expectation
$E[X] = np$
Each of the $n$ trials contributes $p$ successes on average.
Variance
$\text{Var}(X) = np(1-p)$
Exactly $n$ times the variance of one trial, so it is widest at $p = 0.5$.

Where these come from

Write $X = X_1 + \cdots + X_n$ as a sum of independent Bernoulli$(p)$ indicators. Expectations always add, giving $np$, and because the trials are independent the variances add too, giving $np(1-p)$.

Example
Free throws

A player makes $70\%$ of free throws and takes $10$ of them in a game. What is the probability of making exactly $8$?

1
Identify the parameters: $n = 10$, $p = 0.7$, and the question asks for $k = 8$
2
Apply the formula: there are $\dbinom{10}{8} = 45$ orderings, so
$p_X(8) = 45 \times (0.7)^8 \times (0.3)^2 \approx 0.2335$
3
Read the mean: $E[X] = 10 \times 0.7 = 7$ successful free throws per game on average

Making 8 is above average but not unusual: it happens in roughly one game out of four.

Interactive
Shape the PMF with n and p

Move the sliders and watch the shape change: a small $p$ pushes mass toward $0$, a large $p$ pushes it toward $n$, and the middle case gives the familiar bell-like shape.

15
0.40
P(X = k)
Properties
Shape and connections

Shape of the PMF

A single hump with its peak near $np$. It is skewed right for small $p$, skewed left for large $p$, and close to symmetric around $p = 0.5$.


Closed under addition

Two independent Binomials that share the same $p$ add up to another Binomial, exactly as if the trials had been run as one larger batch.

$X + Y \sim \text{Binomial}(n_1 + n_2, \, p)$

Link to the other distributions

Setting $n = 1$ gives back the Bernoulli. Letting $n \to \infty$ and $p \to 0$ with $np = \lambda$ held fixed gives the Poisson, which is section 06.

Notation
Introduced in this section
SymbolMeaning
$X \sim \text{Binomial}(n,p)$number of successes out of $n$ independent trials, each with success probability $p$
$n$fixed number of trials, decided before the experiment starts
$\dbinom{n}{k}$binomial coefficient, the number of ways to choose $k$ successes out of $n$ trials
03

Geometric Distribution

Definition
Waiting for the first success

Repeat independent Bernoulli$(p)$ trials until the first success shows up. $X$ counts how many trials that takes, including the successful one, so the smallest possible value is $1$.

Probability mass function

$p_X(k) = (1-p)^{k-1}\,p, \quad k = 1, 2, 3, \dots$

Parameters and support

p ∈ (0, 1) k = 1, 2, 3, … no upper limit
Expectation and variance
Mean and spread of the waiting time
Expectation
$E[X] = \dfrac{1}{p}$
If a success turns up once every $p$ trials, the wait is $1/p$ trials long.
Variance
$\text{Var}(X) = \dfrac{1-p}{p^2}$
Grows without bound as $p$ shrinks: rare successes make the waiting time highly variable.

Where these come from

A one-step argument is quickest. The first trial either succeeds or resets the problem, so $E[X] = 1 + (1-p)E[X]$, which rearranges to $E[X] = 1/p$. The same conditioning applied to $E[X^2]$ gives the variance.

Example
Rolling a die until a six

Roll a fair die repeatedly. What is the probability the first six appears exactly on the third roll?

1
Identify the parameters: $p = \tfrac{1}{6}$ per roll, and the question asks for $k = 3$
2
Apply the formula: two non-sixes followed by a six, so
$p_X(3) = \left(\dfrac{5}{6}\right)^2 \times \dfrac{1}{6} \approx 0.1157$
3
Read the mean: $E[X] = 1/p = 6$ rolls until the first six on average

Waiting for a target of $r$ successes instead of just one gives the Negative Binomial in the next section.

Interactive
See the mass decrease trial by trial

Move the slider to change $p$. A small $p$ spreads the probability across many trials, a large $p$ concentrates it near $k = 1$.

0.25
P(X = k)
Properties
Shape and connections

Shape of the PMF

Always decreasing. The tallest bar is at $k = 1$ and every following bar is the previous one multiplied by $1-p$, which is why the tail decays geometrically.


Memorylessness

If no success has happened in the first $s$ trials, the number of extra trials still needed behaves like a fresh Geometric. Past failed attempts leave no trace, so ten sixless rolls do not make the eleventh roll any more promising.

$P(X > s+t \mid X > s) = P(X > t)$

Link to the other distributions

It is the Negative Binomial with $r = 1$, and the discrete counterpart of the exponential distribution, which is the only continuous distribution that is also memoryless.

Notation
Introduced in this section
SymbolMeaning
$X \sim \text{Geometric}(p)$number of trials up to and including the first success
$k$index of the trial on which the first success lands, starting at 1
$P(X > t)$tail probability, here equal to $(1-p)^t$: no success in the first $t$ trials
04

Negative Binomial Distribution

Definition
Waiting for the r-th success

The Geometric idea taken one step further: instead of stopping at the first success, keep going until the $r$-th success shows up. $X$ counts the total number of trials needed.

Probability mass function

$p_X(k) = \dbinom{k-1}{r-1} p^r (1-p)^{k-r}, \quad k = r, r+1, \dots$

Parameters and support

r ∈ {1, 2, …} p ∈ (0, 1) k = r, r+1, …
Expectation and variance
Mean and spread of the total wait
Expectation
$E[X] = \dfrac{r}{p}$
$r$ geometric waits stacked one after another, each of length $1/p$ on average.
Variance
$\text{Var}(X) = \dfrac{r(1-p)}{p^2}$
Also $r$ times the geometric variance, so a bigger target spreads the wait out further.

Where these come from

Split the wait into $r$ independent stretches: the trials until the first success, then until the second, and so on. Each stretch is Geometric$(p)$, so both the mean and the variance are just $r$ copies of the geometric ones.

Example
Sales calls until the third sale

A salesperson closes $20\%$ of calls. What is the probability that the third sale happens exactly on the tenth call?

1
Identify the parameters: $r = 3$, $p = 0.2$, and the question asks for $k = 10$
2
Apply the formula: the first two sales sit anywhere among the first 9 calls, $\dbinom{9}{2} = 36$ ways, so
$p_X(10) = 36 \times (0.2)^3 \times (0.8)^7 \approx 0.0604$
3
Read the mean: $E[X] = 3 / 0.2 = 15$ calls to land 3 sales on average

The tenth call is an early finish compared to the average of fifteen, which is why its probability is only about $6\%$.

Interactive
Change the target number of successes

Move the sliders to change $r$, the number of successes to wait for, and $p$, the chance of success on each trial. Setting $r = 1$ brings back the Geometric shape from the previous section.

3
0.30
P(X = k)
Properties
Shape and connections

Shape of the PMF

Mass starts at $k = r$, climbs to a peak and then decays. A larger $r$ pushes that peak to the right and flattens the curve, since more successes mean a longer and less predictable wait.


Closed under addition

Waiting for $r_1$ successes and then for $r_2$ more is the same as waiting for $r_1 + r_2$ from the start, as long as $p$ is shared.

$\text{NegBinom}(r_1, p) + \text{NegBinom}(r_2, p) \sim \text{NegBinom}(r_1 + r_2, \, p)$

Link to the other distributions

Setting $r = 1$ recovers the Geometric exactly. It is the waiting-time counterpart of the Binomial: the Binomial fixes the trials and counts successes, this one fixes the successes and counts trials.

Notation
Introduced in this section
SymbolMeaning
$X \sim \text{NegBinom}(r,p)$number of trials up to and including the $r$-th success
$r$fixed target number of successes, decided before the experiment starts
$\dbinom{k-1}{r-1}$ways to place the first $r-1$ successes among the first $k-1$ trials
05

Poisson Distribution

Definition
Counting rare events over an interval

The Poisson distribution counts how many times an event happens in a fixed interval of time or space, when events occur independently at a constant average rate $\lambda$. Unlike the Binomial, there is no fixed number of trials behind it.

Probability mass function

$p_X(k) = \dfrac{e^{-\lambda}\,\lambda^k}{k!}, \quad k = 0, 1, 2, \dots$

Parameters and support

λ > 0 k = 0, 1, 2, … no fixed n
Expectation and variance
Mean and spread of the event count
Expectation
$E[X] = \lambda$
The rate is the average count over the interval, by construction.
Variance
$\text{Var}(X) = \lambda$
Equal to the mean, which only happens for the Poisson among the distributions here.

Where these come from

Read them off the Binomial limit. Take Binomial$(n, \lambda/n)$ and let $n \to \infty$: the mean $np = \lambda$ stays put, while the variance $np(1-p) = \lambda(1 - \lambda/n)$ climbs to $\lambda$ as $p$ vanishes.

Example
Typos on a page

A book averages $2.3$ typos per page. What is the probability a randomly chosen page has exactly $2$ typos?

1
Identify the parameters: $\lambda = 2.3$ per page, and the question asks for $k = 2$
2
Apply the formula:
$p_X(2) = \dfrac{e^{-2.3}\,(2.3)^2}{2!} \approx 0.2652$, and a clean page has $p_X(0) = e^{-2.3} \approx 0.1003$
3
Read the mean: $E[X] = \lambda = 2.3$ typos per page, with the same value for the variance

The same setup fits calls arriving at a helpdesk per hour, cars passing a sensor per minute, or particles detected per second.

Interactive
Raise the rate and watch the shape shift

Move the slider to change $\lambda$. Small rates keep the mass near $0$, larger rates push it rightward and spread it into a wider, more symmetric hump.

2.3
P(X = k)
Properties
Shape and connections

Shape of the PMF

The peak sits at $\lfloor \lambda \rfloor$. Small rates leave most of the mass at $0$ and give a sharply skewed shape, while large rates drift right and look increasingly symmetric.


Rates add up

Combining two independent streams of rare events gives another Poisson stream whose rate is the sum of the two.

$X + Y \sim \text{Poisson}(\lambda_1 + \lambda_2)$

Link to the other distributions

It is the limit of the Binomial when trials are many and successes are rare, which is what section 06 works through numerically. The gaps between consecutive Poisson events follow an exponential distribution.

Notation
Introduced in this section
SymbolMeaning
$X \sim \text{Poisson}(\lambda)$count of events in a fixed interval with average rate $\lambda$
$\lambda$expected number of events in that interval, both mean and variance
$k!$factorial, correcting for the orderings of the $k$ events within the interval
06

From Binomial to Poisson

Approximation
When trials are many and success is rare

Take a Binomial$(n,p)$ where $n$ is large and $p$ is small, while their product $np = \lambda$ stays fixed at a moderate value. Under these conditions, the Binomial PMF gets closer and closer to a Poisson PMF with that same $\lambda$.

$\dbinom{n}{k} p^k (1-p)^{n-k} \ \xrightarrow[\ np = \lambda\ ]{n \to \infty} \ \dfrac{e^{-\lambda}\,\lambda^k}{k!}$

Rule of thumb for using the approximation

n ≥ 20 p ≤ 0.05 λ = np, moderate size
Example
Manufacturing defects

A factory produces $n = 2000$ chips, each defective independently with $p = 0.001$. Here $n$ is large and $p$ is tiny, so $\lambda = np = 2$ is a good Poisson rate to approximate the exact Binomial.

kBinomial(2000, 0.001)Poisson(2)
00.13520.1353
10.27070.2707
20.27080.2707
30.18050.1804
40.09020.0902

The two columns line up to four decimal places. This is exactly why the Poisson distribution is used to model rare events without needing to track the exact number of trials behind them.

07

The Birthday Paradox

Setup
How many people until two share a birthday?

Ignore leap years and assume all $365$ birthdays are equally likely. With $n$ people in a room, how likely is it that at least two of them share a birthday? It is easier to compute the complement: the probability that all $n$ birthdays are different.

$P(\text{no shared birthday}) = \dfrac{365}{365} \times \dfrac{364}{365} \times \cdots \times \dfrac{365-n+1}{365}$

$P(\text{at least one shared birthday}) = 1 - \displaystyle\prod_{i=0}^{n-1} \dfrac{365-i}{365}$
Example
Why 23 people is enough

The "paradox" in the name comes from how small $n$ needs to be. It feels like it should take hundreds of people, but $23$ is already enough to cross $50\%$.

1
With 10 people: $P \approx 0.117$, only about 1 in 9
2
With 23 people: $P \approx 0.507$, just over a coin flip
3
With 50 people: $P \approx 0.970$, almost certain

The reason is that probability grows with the number of pairs of people, not the number of people itself, and pairs grow much faster: $23$ people already form $\binom{23}{2} = 253$ pairs.

Interactive
Drag the group size and watch the probability climb

Move the slider to change how many people are in the room. The dashed line marks $50\%$, and the highlighted point shows exactly where the current group size lands on the curve.

23
P(shared birthday)
08

How the Distributions Connect

Overview
Everything starts from a single Bernoulli trial

The distributions in this visual guide are not unrelated, they are different questions asked about the same repeated Bernoulli$(p)$ trial: how many successes in a fixed number of trials, or how many trials until a target number of successes.

Starting pointQuestion askedDistribution
Bernoulli(p)fix the number of trials $n$, count successesBinomial(n, p)
Bernoulli(p)count trials needed for 1 successGeometric(p)
Bernoulli(p)count trials needed for $r$ successesNegBinom(r, p)
Binomial(n, p)let $n \to \infty$, $p \to 0$, $np = \lambda$ fixedPoisson(λ)
NegBinom(r, p)set $r = 1$Geometric(p)
09

Cheat Sheet

Summary
All five distributions compared
DistributionPMFSupportMeanVariance
Bernoulli(p) $p^k(1-p)^{1-k}$ $k \in \{0,1\}$ $p$ $p(1-p)$
Binomial(n, p) $\binom{n}{k}p^k(1-p)^{n-k}$ $k = 0,\dots,n$ $np$ $np(1-p)$
Geometric(p) $(1-p)^{k-1}p$ $k = 1,2,\dots$ $1/p$ $(1-p)/p^2$
NegBinom(r, p) $\binom{k-1}{r-1}p^r(1-p)^{k-r}$ $k = r, r+1,\dots$ $r/p$ $r(1-p)/p^2$
Poisson(λ) $e^{-\lambda}\lambda^k/k!$ $k = 0,1,2,\dots$ $\lambda$ $\lambda$