The Bernoulli Distribution
Flip a coin: heads or tails. Click an advert: clicked or ignored. Take a penalty: goal or miss.
Test a light bulb: works or dud. Each of these is the very simplest random experiment there is —
a single trial with exactly two outcomes. Give the outcome you care about the
label success and score it 1; call the other
failure and score it 0. The
distribution
of that one-or-zero is the Bernoulli distribution, named after
Jacob Bernoulli.
It has a single knob: p, the
probability
of success. We write
X \sim \text{Bernoulli}(p),
read "X is distributed as Bernoulli with success probability
p". That one number p is the whole story: it
fixes how often the 1 turns up, and everything below —
the mean, the variance, the shape — follows from it.
Look for any yes/no question about a single thing and you have found a Bernoulli
trial. Heads or tails (p = 0.5). A newborn is a girl or a boy
(p \approx 0.49). A visitor to a web page clicks the button or leaves
(p maybe 0.03). A patient responds to a drug
or doesn't. Even a "true/false" exam guess is a Bernoulli trial with
p = 0.5. Whenever an event either happens or doesn't,
the little indicator "did it happen? (1 = yes, 0 = no)" is Bernoulli — which is why it is often
called the indicator of the event.
The probability mass function
A Bernoulli variable can only ever be 0 or 1, so
its distribution is just two probabilities that must add to 1:
P(X = 1) = p, \qquad P(X = 0) = 1 - p.
That's the entire probability mass function (PMF) — two bars, one of height
p at 1 and one of height
1 - p at 0. The failure probability
1 - p is written so often it gets its own letter,
q = 1 - p, so p + q = 1.
There is a neat one-line way to write both cases at once. Because
x is either 0 or
1,
P(X = x) = p^{\,x}(1-p)^{\,1-x}, \qquad x \in \{0, 1\}.
Check it: put x = 1 and you get
p^{1}(1-p)^{0} = p; put x = 0 and you get
p^{0}(1-p)^{1} = 1-p. The exponents simply switch the formula between the
two outcomes.
Mean and variance
The mean (expected value) is an average of the outcomes
0 and 1 weighted by their probabilities:
E[X] = 0 \cdot (1-p) + 1 \cdot p = p.
So the mean of a Bernoulli is just p — the long-run fraction of
trials that succeed. Flip a coin many times and the average of the
0s and 1s settles near
0.5.
The variance follows from a slick trick. Since X is only
ever 0 or 1, squaring changes nothing:
X^2 = X. Therefore E[X^2] = E[X] = p, and
\operatorname{Var}(X) = E[X^2] - (E[X])^2 = p - p^2 = p(1-p).
- A single trial with two outcomes: X = 1 (success) with probability
p, else X = 0.
- PMF: P(X = 1) = p and
P(X = 0) = 1 - p.
- Mean: E[X] = p.
- Variance: \operatorname{Var}(X) = p(1-p), which is
largest at p = 0.5 and zero at
p = 0 or p = 1.
Worked example 1 — a biased coin
A bent coin comes up heads 70\% of the time. Let
X = 1 for heads, so X \sim \text{Bernoulli}(0.7).
Write down its distribution and its summary numbers.
The PMF. Just the two probabilities:
P(X = 1) = 0.7, \qquad P(X = 0) = 1 - 0.7 = 0.3.
The mean. Straight from E[X] = p:
E[X] = 0.7.
The variance. From p(1-p):
\operatorname{Var}(X) = 0.7 \times 0.3 = 0.21,
so the standard deviation is \sqrt{0.21} \approx 0.458. The mean
0.7 sits between the only two values the coin can score, which is exactly
why a single flip is so uncertain: the "average" outcome 0.7 never
actually happens.
Worked example 2 — when is a coin most unpredictable?
The variance p(1-p) measures how much a single trial wobbles.
Let's tabulate it and see where it is biggest:
- p = 0: variance 0 \times 1 = 0 — the trial
always fails, no surprise at all.
- p = 0.1: variance 0.1 \times 0.9 = 0.09.
- p = 0.3: variance 0.3 \times 0.7 = 0.21.
- p = 0.5: variance 0.5 \times 0.5 = 0.25 —
the maximum.
- p = 0.7: variance 0.7 \times 0.3 = 0.21.
- p = 1: variance 1 \times 0 = 0 — the trial
always succeeds, again no surprise.
The variance is a downward parabola in p, pinned to
0 at both ends and peaking dead centre at
p = 0.5. That matches intuition perfectly: a
fair coin is the hardest to call, while a coin that is certain to land one way (
p = 0 or 1) carries no uncertainty at all.
A quick calculus check confirms it — the derivative of p - p^2 is
1 - 2p, which is zero exactly at p = 0.5.
See it: the two bars and the variance curve
Drag the p slider. On the left the two PMF bars trade height — push
p up and the success bar (at 1) grows while the
failure bar (at 0) shrinks, always summing to 1.
On the right the marker rides the variance parabola p(1-p): watch it climb
to its peak at p = 0.5 and drop back to 0 as
p heads for either extreme.
-
Don't confuse the Bernoulli with the Binomial. A Bernoulli is
one trial, and X is 0 or
1. A
binomial
counts successes over n trials, so
X ranges 0, 1, \ldots, n. The Bernoulli is
the single building block; a B(n, p) is a sum of
n independent Bernoulli trials. In fact
\text{Bernoulli}(p) is exactly B(1, p).
-
The variance peaks in the middle, not at the extremes.
p(1-p) is largest at p = 0.5 (most
uncertain) and zero at p = 0 or
p = 1 (a sure thing). It is tempting to think a very likely event is
"high variance" — it isn't; near-certainty means near-zero spread.
-
Which outcome is "success" is your choice. Labelling heads as success gives
p; labelling tails as success gives 1 - p.
The mean flips accordingly, but the variance p(1-p) is the same either
way — it's symmetric in p and 1 - p.
The atom of probability
The Bernoulli is the simplest non-trivial random variable, and almost every discrete distribution is
built from it. Add up n independent Bernoulli trials and you get the
binomial.
Keep flipping until the first success and the number of trials you needed follows the
geometric distribution.
Because "did this event happen?" is a Bernoulli question, its mean
p is also the tidiest way to say "the probability of the event" — the
indicator's average is the probability. Master this one atom and the bigger distributions
fall into place.