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.

a coin

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).

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:

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.

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.