Variance of the Bernoulli Distribution
First, the intuition
Imagine a single coin flip — but not a fair coin. Let’s say the coin lands Heads with probability p and Tails with probability 1−p. We code Heads as 1 and Tails as 0. That’s a Bernoulli trial: a single experiment with exactly two outcomes.
Now ask: how "spread out" is this outcome? The answer is not obvious because there are only two possible values, 0 and 1. The spread depends entirely on p.
If p=0 or p=1, the outcome is certain — no spread at all. If p=0.5, the outcome is maximally uncertain: half the time you get 0, half the time 1. That’s when the spread is largest.
Variance measures exactly this spread — the average squared distance of the outcome from its mean.
The mean first
The mean (expected value) of a Bernoulli random variable X is:
E[X]=1⋅p+0⋅(1−p)=p
So the "centre" of the distribution is at p. For a fair coin, the mean is 0.5 — a number that never actually occurs, but that’s fine; it’s the long-run average.
Now variance
Variance is defined as:
Var(X)=E[(X−E[X])2]
That is: take each possible outcome, subtract the mean, square the result, then average those squared deviations (weighted by their probabilities).
For Bernoulli:
- When X=1: deviation is 1−p, squared is (1−p)2, weight is p.
- When X=0: deviation is 0−p=−p, squared is p2, weight is 1−p.
So:
Var(X)=p(1−p)2+(1−p)p2
Factor p(1−p):
Var(X)=p(1−p)[(1−p)+p]=p(1−p)(1)
Var(X)=p(1−p)
That’s it. One clean expression.
What the formula tells you
- When p=0 or p=1, variance is 0 — no uncertainty.
- When p=0.5, variance is 0.5×0.5=0.25, the maximum possible.
- The variance is symmetric: swapping p and 1−p gives the same number. That makes sense — calling Heads "success" vs "failure" shouldn’t change the spread. …