Unit 6, lesson 38

The Bernoulli Distribution

How a Bernoulli variable records one success or failure as 1 or 0, what its parameter means, why its mean is the success probability, and when its variance is zero or as large as it can be.

  • Video 38
  • Uniform and Bernoulli Distributions

Many questions about a random experiment have a yes or no answer. Does this package need a manual label check? Does the lamp pass its test? Recording yes as 11 and no as 00 turns the answer into a random variable that takes only the values 00 and 11, and a single probability then describes its whole distribution. This lesson builds that distribution, derives its mean and variance, and separates what it says about one trial from what it leaves open about several.

Key terms

Bernoulli trial and success

Definition A Bernoulli trial is one run of a random experiment together with one event AA whose occurrence is recorded. The event AA is called success and its complement AcA^{c} is called failure. Coding success as 11 and failure as 00 gives the indicator IAI_A, which equals 11 on outcomes in AA and 00 on all other outcomes. Many texts use the plural phrase “Bernoulli trials” only for independent trials with a common success probability. Independence and a common success probability are extra assumptions about the whole sequence, and they do not follow from each trial having two recorded results.

In plain words Success is a name for the event you chose to record, not a judgment. A defect, a delay or a failed test can be the success if that is the event being counted. The experiment itself may have many outcomes, as long as each one is sorted into the event or its complement.

Example Roll a fair die and call a six a success. The die has six outcomes, but the trial records only whether A={6}A = \{6\} occurred, so IA=1I_A = 1 with probability 16\tfrac{1}{6}. For a package on a sorting line, the success can be the event that it needs a manual label check, even though nobody hopes for that. Now draw two tokens without replacement from a bag with 44 marked tokens among 1010, and record a marked token as success. Each draw is a Bernoulli trial with success probability 410\tfrac{4}{10} before anything is seen, yet after a marked first draw the second is marked with probability 39\tfrac{3}{9}. The two trials are dependent.

Bernoulli distribution

Definition Let 0≤p≤10 \le p \le 1. A random variable BB has the Bernoulli distribution with parameter pp, written B∼Bernoulli⁡(p)B \sim \operatorname{Bernoulli}(p), if its PMF has

pB(1)=p,pB(0)=1−p,\begin{gathered} p_B(1) = p, \\[0.4em] p_B(0) = 1 - p, \end{gathered}

and pB(b)=0p_B(b) = 0 for every other bb. The two masses are nonnegative and add to 11 for every pp in [0,1][0, 1], so this is a valid distribution. Every indicator IAI_A is Bernoulli with parameter P(A)P(A). Some books write the PMF as pb(1−p)1−bp^{b}(1 - p)^{1 - b} for b∈{0,1}b \in \{0, 1\}, which relies on the convention 00=10^0 = 1 when pp is 00 or 11.

In plain words A Bernoulli variable is a yes or no answer written as a number. Its whole distribution is fixed by one probability, the chance of a 11. Questions about BB are answered by translating the event into the values 00 and 11.

Example Let B=1B = 1 if a package needs a manual check and B=0B = 0 otherwise, with P(B=1)=320P(B = 1) = \tfrac{3}{20} in this constructed model. Then B∼Bernoulli⁡(3/20)B \sim \operatorname{Bernoulli}(3/20) and P(B=0)=1720P(B = 0) = \tfrac{17}{20}. The event B≥1B \ge 1 holds only at the value 11, so P(B≥1)=320P(B \ge 1) = \tfrac{3}{20}, while P(B>1)=0P(B > 1) = 0 because no possible value exceeds 11.

Parameter of a distribution

Definition A parameter is a number, or a list of numbers, that selects one distribution from a family described by a common formula. The set of allowed values is the parameter space. The Bernoulli family has one parameter pp with parameter space [0,1][0, 1], and each value of pp gives exactly one PMF. If B∼Bernoulli⁡(p)B \sim \operatorname{Bernoulli}(p), the reversed coding C=1−BC = 1 - B satisfies C∼Bernoulli⁡(1−p)C \sim \operatorname{Bernoulli}(1 - p), because it exchanges the two masses.

In plain words The family gives the formula, and the parameter fills in what the formula leaves open, which for the Bernoulli family is the one number pp. The parameter belongs to the model. The fraction of checked packages in one batch is an observed frequency, and it can differ from pp. Different trials can belong to the same family with different parameters.

Example For the package model, B∼Bernoulli⁡(3/20)B \sim \operatorname{Bernoulli}(3/20). The indicator of no manual check is C=1−BC = 1 - B, which equals 11 exactly when B=0B = 0, so C∼Bernoulli⁡(17/20)C \sim \operatorname{Bernoulli}(17/20). A fragile label type with a higher check probability, say 310\tfrac{3}{10}, is described by another member of the same family, and treating both label types as one trial type with a single pp would misdescribe them.

Mean and variance of a Bernoulli variable

Definition If B∼Bernoulli⁡(p)B \sim \operatorname{Bernoulli}(p), then

E[B]=1⋅p+0⋅(1−p)=p.\begin{aligned} E[B] &= 1 \cdot p + 0 \cdot (1 - p) \\[0.4em] &= p. \end{aligned}

Because 02=00^2 = 0 and 12=11^2 = 1, the variable satisfies B2=BB^2 = B, so E[B2]=pE[B^2] = p and

Var⁡(B)=E[B2]−(E[B])2=p−p2=p(1−p).\begin{aligned} \operatorname{Var}(B) &= E[B^2] - (E[B])^2 \\[0.4em] &= p - p^2 \\[0.4em] &= p(1 - p). \end{aligned}

The standard deviation is SD⁡(B)=p(1−p)\operatorname{SD}(B) = \sqrt{p(1 - p)}. For an indicator these give E[IA]=P(A)E[I_A] = P(A) and Var⁡(IA)=P(A)(1−P(A))\operatorname{Var}(I_A) = P(A)\bigl(1 - P(A)\bigr).

In plain words The mean of a variable that is 00 or 11 is the probability of a 11. It is an average over the model, and when 0<p<10 < p < 1 it is not a value the variable can take. Squaring a 00 or a 11 changes nothing, so the second moment equals the mean, and subtracting the squared mean leaves p(1−p)p(1 - p).

Example For the package indicator with p=320p = \tfrac{3}{20}, the mean is E[B]=320=0.15E[B] = \tfrac{3}{20} = 0.15. No package receives 0.150.15 of a check. Each package gives 00 or 11, and 0.150.15 is the probability-weighted average of those values. The variance is

Var⁡(B)=320⋅1720=51400=0.1275,\begin{aligned} \operatorname{Var}(B) &= \frac{3}{20} \cdot \frac{17}{20} \\[0.4em] &= \frac{51}{400} = 0.1275, \end{aligned}

and SD⁡(B)=51/20≈0.357\operatorname{SD}(B) = \sqrt{51}/20 \approx 0.357. If ordinary processing costs 22 units and a manual check adds 88 more, the cost is 2+8B2 + 8B, and linearity gives the expected cost 2+8⋅320=165=3.22 + 8 \cdot \tfrac{3}{20} = \tfrac{16}{5} = 3.2 units. The table of costs agrees, since 2⋅1720+10⋅320=64202 \cdot \tfrac{17}{20} + 10 \cdot \tfrac{3}{20} = \tfrac{64}{20}.

Degenerate distribution

Definition A random variable XX has a degenerate distribution if P(X=c)=1P(X = c) = 1 for some constant cc. Its variance is then 00, and conversely a variable with variance 00 satisfies P(X=E[X])=1P(X = E[X]) = 1. The Bernoulli distributions with p=0p = 0 and p=1p = 1 are degenerate, at 00 and at 11. For 0<p<10 < p < 1 both values 00 and 11 have positive probability and Var⁡(B)=p(1−p)>0\operatorname{Var}(B) = p(1 - p) > 0.

In plain words A degenerate variable takes one value with probability 11, so there is nothing left to predict. It is still a valid distribution. At the endpoints it is clearer to read the PMF directly than to evaluate pb(1−p)1−bp^{b}(1 - p)^{1 - b} with a 000^0 in it.

Example In a model where a lamp passes its test with probability 11, the indicator of failure is Bernoulli⁡(0)\operatorname{Bernoulli}(0). It equals 00 with probability 11, its mean is 00 and its variance is 0⋅1=00 \cdot 1 = 0. The indicator of passing is Bernoulli⁡(1)\operatorname{Bernoulli}(1), with mean 11 and variance 1⋅0=01 \cdot 0 = 0.

Maximum Bernoulli variance

Definition For every pp in [0,1][0, 1],

p(1−p)=14−(p−12)2≤14,\begin{aligned} p(1 - p) &= \frac{1}{4} - \Bigl(p - \frac{1}{2}\Bigr)^2 \\[0.4em] &\le \frac{1}{4}, \end{aligned}

with equality exactly when p=12p = \tfrac{1}{2}. So a Bernoulli variance is at most 14\tfrac{1}{4}, a Bernoulli standard deviation is at most 12\tfrac{1}{2}, and both maxima occur only at p=12p = \tfrac{1}{2}. The variance takes the same value at pp and at 1−p1 - p.

In plain words The result is hardest to predict when 00 and 11 are equally likely. As pp moves away from 12\tfrac{1}{2} toward 00 or 11, one value dominates and the variance shrinks, reaching 00 at the endpoints. Coding the other event as success replaces pp by 1−p1 - p and leaves the variance unchanged.

Example The package indicator with p=0.15p = 0.15 has variance 0.12750.1275. A lamp indicator with p=0.3p = 0.3 or with p=0.7p = 0.7 has variance 0.210.21, and a fair coin has the largest possible value 0.250.25. No Bernoulli variable has variance 0.30.3, since that exceeds 14\tfrac{1}{4}. A variance of 0.210.21 does not determine pp, because both 0.30.3 and 0.70.7 give it.

Check yourself

  1. A lamp works on its test with probability 0.70.7. Let W=1W = 1 if it works and W=0W = 0 if it fails, and let F=1F = 1 if it fails and F=0F = 0 if it works. Give the distributions of WW and FF with their means and variances.
Show the answer

The variable WW is Bernoulli⁡(0.7)\operatorname{Bernoulli}(0.7), with mean 0.70.7 and variance 0.7⋅0.3=0.210.7 \cdot 0.3 = 0.21. The failure indicator is F=1−WF = 1 - W, which is Bernoulli⁡(0.3)\operatorname{Bernoulli}(0.3) with mean 0.30.3 and the same variance 0.3⋅0.7=0.210.3 \cdot 0.7 = 0.21. These are two codings of the same test, not two independent observations. Whenever one of them is 11, the other is 00.

  1. Each lamp test costs 33 units, and a failure adds 55 more. Find the expected cost of one test in two ways.
Show the answer

The cost is 33 when the lamp works and 88 when it fails, so the table gives 3⋅0.7+8⋅0.3=2.1+2.4=4.53 \cdot 0.7 + 8 \cdot 0.3 = 2.1 + 2.4 = 4.5 units. The cost can also be written as 3+5F3 + 5F, and linearity gives 3+5⋅0.3=4.53 + 5 \cdot 0.3 = 4.5 units.

  1. Two packages each need a manual check with probability 320\tfrac{3}{20}. Is the probability that both need checks equal to (320)2=9400\bigl(\tfrac{3}{20}\bigr)^2 = \tfrac{9}{400}?
Show the answer

Not necessarily. The product rule holds exactly when the two check indicators are independent, and their Bernoulli laws say nothing about that. Suppose a shared printing fault makes the two packages either both need a check or both pass, with the check happening with probability 320\tfrac{3}{20}. Each indicator is still Bernoulli⁡(3/20)\operatorname{Bernoulli}(3/20), but the probability that both need checks is 320\tfrac{3}{20}, not 9400\tfrac{9}{400}. In general these two marginal laws allow any value from 00 to 320\tfrac{3}{20} for that probability, so the way the packages are linked has to be modeled separately.

How this lesson connects