The Bernoulli Distribution: One Trial, Two Outcomes

A Bernoulli random variable XX describes the outcome of a single trial that can end in only two ways: success (X=1X=1) with probability pp, or failure (X=0X=0) with probability 1−p1-p.


It is the building block for many other discrete distributions, but on its own it always involves exactly one trial.


Which outcome is labelled 'success' is a modelling choice, not a value judgement: a spam filter may call a spam email a success simply because that is the event being counted.

Probability mass function of a Bernoulli random variable X, where X = 1 if a customer clicks an ad and X = 0 otherwise.

Probability mass function of a Bernoulli random variable XX, where X=1X = 1 if a customer clicks an ad and X=0X = 0 otherwise.

Variance of a Bernoulli random variable as a function of the success probability

Variance of a Bernoulli random variable as a function of the success probability

Probability mass function

For x∈{0,1}x \in \{0,1\}:


P(X=x)=px(1−p)1−xP(X=x)=p^{x}(1-p)^{1-x}


which just means P(X=1)=pP(X=1)=p and P(X=0)=1−pP(X=0)=1-p. Nothing else is possible, there is no P(X=2)P(X=2) or P(X=0.5)P(X=0.5). A candidate PMF is only Bernoulli if it assigns probabilities to exactly the outcomes 0 and 1, keeps both in [0,1][0,1], and has them sum to 1.

Mean and variance

Because XX takes only the values 0 and 1, its expectation collapses to the success probability itself:


E[X]=∑x P(X=x)=0⋅(1−p)+1⋅p=pE[X]=\sum x\,P(X=x)=0\cdot(1-p)+1\cdot p=p


Var(X)=E[X2]−(E[X])2=p−p2=p(1−p)\text{Var}(X)=E[X^2]-(E[X])^2=p-p^2=p(1-p)


The second line uses E[X2]=E[X]E[X^2]=E[X], which holds because 02=00^2=0 and 12=11^2=1, a shortcut available only for indicator-type variables. Note that Var(X)\text{Var}(X) is zero when p=0p=0 or p=1p=1, since the outcome is then certain, and it is largest in the middle of the range where the outcome is least predictable.


The variance is also symmetric: pp and 1−p1-p give the same value, so a trial with p=0.2p=0.2 and one with p=0.8p=0.8 are equally variable.

Linear functions of a Bernoulli variable

If Y=aX+bY=aX+b then E[Y]=ap+bE[Y]=ap+b and Var(Y)=a2p(1−p)\text{Var}(Y)=a^{2}p(1-p). Adding a constant shifts every outcome by the same amount and so cannot change the spread, while multiplying by aa stretches every deviation by aa and therefore scales the variance by a2a^{2}. This is how a two-outcome cost or payout is analysed.

Worked example

A single manufactured bolt passes inspection with probability p=0.9p=0.9. Let X=1X=1 if it passes. Then E[X]=0.9E[X]=0.9 and Var(X)=0.9(0.1)=0.09\text{Var}(X)=0.9(0.1)=0.09, so σX=0.09=0.3\sigma_X=\sqrt{0.09}=0.3. The standard deviation is in the same (unitless) scale as XX itself, which is why it is reported instead of the variance when a spread is quoted alongside the mean.



The figure shows the probability mass function of a Bernoulli random variable XX, where X=1X=1 if a customer clicks an online ad and X=0X=0 otherwise. Using the figure, what is E[X]E[X]?

Probability mass function of a Bernoulli random variable X, where X = 1 if a customer clicks an ad and X = 0 otherwise.

Probability mass function of a Bernoulli random variable XX, where X=1X = 1 if a customer clicks an ad and X=0X = 0 otherwise.

Variance of a Bernoulli random variable as a function of the success probability

Variance of a Bernoulli random variable as a function of the success probability

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Which of the following is a valid probability mass function for a Bernoulli random variable XX?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

The graph shows Var(X)=p(1−p)\text{Var}(X)=p(1-p) for a Bernoulli random variable XX as a function of pp. Two production lines each produce one item, defective with probability p=0.1p=0.1 on the first line and p=0.3p=0.3 on the second. Using the graph, approximately how many times larger is the variance of the second line's Bernoulli outcome than the first line's?

Probability mass function of a Bernoulli random variable X, where X = 1 if a customer clicks an ad and X = 0 otherwise.

Probability mass function of a Bernoulli random variable XX, where X=1X = 1 if a customer clicks an ad and X=0X = 0 otherwise.

Variance of a Bernoulli random variable as a function of the success probability

Variance of a Bernoulli random variable as a function of the success probability

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors