Bernoulli and Binomial Distributions

Model one binary trial with a Bernoulli variable and count successes across repeated trials with a binomial variable. Derive exact and cumulative probabilities, moments, and sample-proportion behavior, then check the assumptions behind the count model.

Bernoulli and binomial distributions describe binary trials. A Bernoulli variable records one success or failure. A binomial variable counts successes across a fixed number of independent Bernoulli trials with the same success probability.

One Binary Trial

A Bernoulli random variable XX takes two numerical values:

X={1with probability p,0with probability 1p.X= \begin{cases} 1 & \text{with probability }p,\\ 0 & \text{with probability }1-p. \end{cases}

We write XBernoulli(p)X\sim\operatorname{Bernoulli}(p), where 0p10\le p\le1. Calling the outcomes “success” and “failure” is conventional; success need not be desirable. It is simply the event encoded by 11.

The probability mass function can be written compactly as:

P(X=x)=px(1p)1x,x{0,1}.P(X=x)=p^x(1-p)^{1-x}, \qquad x\in\{0,1\}.

“The mass at xx is pp raised to xx, times one minus pp raised to one minus xx.” Substituting the only two allowed values recovers P(X=1)=pP(X=1)=p and P(X=0)=1pP(X=0)=1-p.

Substituting x=1x=1 leaves pp; substituting x=0x=0 leaves 1p1-p. Examples include whether a component fails, whether a user clicks, or whether one prediction is correct—provided the outcome is genuinely binary.

Exercise: Read a Bernoulli parameter

If XBernoulli(0.7)X\sim\operatorname{Bernoulli}(0.7), what is P(X=0)P(X=0)?

Compute it first, then check your number.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintUse the complementary outcome

The masses at zero and one must sum to one.

SolutionAssign the remaining probability to zero

Since P(X=1)=0.7P(X=1)=0.7,

P(X=0)=10.7=0.3.P(X=0)=1-0.7=0.3.

The parameter pp always refers to the outcome encoded as one.

Mean and Variance of a Bernoulli Variable

Because XX is either zero or one,

E[X]=0(1p)+1(p)=p.\mathbb{E}[X]=0(1-p)+1(p)=p.

Also X2=XX^2=X, so:

Var(X)=E[X2]E[X]2=pp2=p(1p).\operatorname{Var}(X) =\mathbb{E}[X^2]-\mathbb{E}[X]^2 =p-p^2 =p(1-p).

The variance is zero at p=0p=0 and p=1p=1, where the outcome is certain. It is largest at p=1/2p=1/2, where uncertainty between the two outcomes is greatest.

Exercise: Compute Bernoulli variance

What is the variance of XBernoulli(0.2)X\sim\operatorname{Bernoulli}(0.2)?

Compute it first, then check your number.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintUse p times one minus p

Calculate 0.2(0.8)0.2(0.8).

SolutionMeasure binary uncertainty

The variance is:

p(1p)=0.2(0.8)=0.16.p(1-p)=0.2(0.8)=0.16.

It is smaller than the maximum 0.250.25 because one outcome is considerably more likely than the other.

Count Successes across Repeated Trials

Let X1,,XnX_1,\ldots,X_n be independent Bernoulli variables with the same parameter pp. Their sum:

K=X1++XnK=X_1+\cdots+X_n

counts the number of successes. We write:

KBinomial(n,p).K\sim\operatorname{Binomial}(n,p).

For k{0,1,,n}k\in\{0,1,\ldots,n\},

P(K=k)=(nk)pk(1p)nk.P(K=k)=\binom{n}{k}p^k(1-p)^{n-k}.

“The probability of exactly kk successes in nn trials equals nn choose kk, times pp to the kk, times one minus pp to the nkn-k.”

One particular sequence with kk successes has probability pk(1p)nkp^k(1-p)^{n-k}. The coefficient:

(nk)=n!k!(nk)!\binom{n}{k}=\frac{n!}{k!(n-k)!}

counts the positions in which those kk successes can occur.

For three fair trials, exactly two successes can appear as SSFSSF, SFSSFS, or FSSFSS. Each sequence has probability (1/2)3=1/8(1/2)^3=1/8, so the total is 3/83/8.

Exercise: Compute a binomial probability

Three independent trials each succeed with probability 0.50.5. What is the probability of exactly two successes?

Compute it first, then check your number.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintCount the possible success positions

There are (32)=3\binom32=3 sequences with two successes.

SolutionCount and weight all matching sequences

Apply the binomial formula:

P(K=2)=(32)(0.5)2(0.5)1=3(18)=38=0.375.P(K=2)=\binom32(0.5)^2(0.5)^1=3\left(\frac18\right)=\frac38=0.375.

Omitting the coefficient would count only one of the three valid sequences.

Binomial Mean and Variance

Since KK is a sum of nn Bernoulli variables, linearity of expectation gives:

E[K]=np.\mathbb{E}[K]=np.

Independence makes the covariance terms zero, so variances add:

Var(K)=np(1p).\operatorname{Var}(K)=np(1-p).

For n=20n=20 and p=0.3p=0.3, the expected count is 66 and the variance is 4.24.2. An expectation of 66 does not say every batch contains six successes; it is the probability-weighted center of the count distribution.

Holding nn fixed while increasing pp moves the distribution toward larger success counts. Holding pp fixed while increasing nn also moves the expected count, npnp, to the right and usually spreads the count over more integer values. In contrast, the sample proportion K/nK/n becomes more concentrated around pp because its variance is p(1p)/np(1-p)/n.

Exercise: Calculate a binomial mean and variance

If KBinomial(10,0.4)K\sim\operatorname{Binomial}(10,0.4), what is E[K]\mathbb{E}[K]?

Compute it first, then check your number.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintMultiply trial count by success probability

Use npnp.

SolutionAdd the expected contributions of ten trials

The expected count is:

E[K]=np=10(0.4)=4.\mathbb{E}[K]=np=10(0.4)=4.

Each trial contributes expected value 0.40.4, and expectation adds even before independence is used.

Exactly, At Most, and At Least

The mass function gives P(K=k)P(K=k) for one exact count. Questions about ranges of counts require adding disjoint masses. For example:

P(K2)=P(K=0)+P(K=1)+P(K=2).P(K\le2)=P(K=0)+P(K=1)+P(K=2).

Complements can shorten an “at least” calculation:

P(K1)=1P(K=0)=1(1p)n.P(K\ge1)=1-P(K=0)=1-(1-p)^n.

For four independent trials with p=0.2p=0.2, the probability of at least one success is:

1(0.8)4=10.4096=0.5904.1-(0.8)^4=1-0.4096=0.5904.

The expression P(K1)P(K\ge1) includes counts 1,2,3,1,2,3, and 44; it is not the same as the exact-count probability P(K=1)P(K=1).

Exercise: Calculate an at-least-one probability

Five independent trials each succeed with probability 0.10.1. What is the probability of at least one success?

Compute it first, then check your number.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintUse the complementary zero-success event

Calculate 1(0.9)51-(0.9)^5.

SolutionSubtract the probability of no successes

The only way to avoid at least one success is to have five failures:

P(K1)=1P(K=0)=1(0.9)5=10.59049=0.40951.P(K\ge1)=1-P(K=0)=1-(0.9)^5=1-0.59049=0.40951.

Counts and Sample Proportions

The sample success proportion is:

p^=Kn.\widehat p=\frac{K}{n}.

Scaling the binomial moments gives:

E[p^]=p,Var(p^)=p(1p)n.\mathbb{E}[\widehat p]=p, \qquad \operatorname{Var}(\widehat p)=\frac{p(1-p)}{n}.

Thus the sample proportion is centered at the trial probability, and its variance decreases as the number of trials grows. This does not mean every large sample gives exactly pp; it means the distribution of p^\widehat p becomes more concentrated around pp.

Exercise: Find the spread of a sample proportion

For n=100n=100 independent Bernoulli trials with p=0.4p=0.4, what is Var(p^)\operatorname{Var}(\widehat p)?

Compute it first, then check your number.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintDivide Bernoulli variance by the sample size

Use p(1p)/np(1-p)/n.

SolutionScale count variance by the square of n

The variance is:

Var(p^)=0.4(0.6)100=0.0024.\operatorname{Var}(\widehat p) =\frac{0.4(0.6)}{100} =0.0024.

Equivalently, divide Var(K)=100(0.4)(0.6)=24\operatorname{Var}(K)=100(0.4)(0.6)=24 by 1002100^2 because p^=K/100\widehat p=K/100.

Check the Modeling Assumptions

A binomial model requires:

  • a fixed number nn of trials;
  • two outcomes per trial;
  • the same success probability pp for every trial;
  • independence between trials.

Sampling ten items with replacement from a large stable population may fit these assumptions. Drawing ten cards without replacement does not: earlier draws change later probabilities. Trials collected over time may also have a changing pp. A count between zero and nn is not enough by itself to justify a binomial model.

Exercise: Reject an invalid binomial model

Five cards are drawn from one deck without replacement, and KK counts the aces. Is KK exactly binomial with one fixed success probability?

Choose one

Select one choice, then check.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintInspect what changes after one draw

The deck composition depends on which card was removed.

SolutionThe repeated trials are not identical and independent

No. After each draw, both the number of remaining cards and possibly the number of remaining aces change. A hypergeometric model, introduced when needed, describes this without-replacement count.

Plot Exact Mass and Simulated Counts

Compare a binomial PMF with simulated counts

Change n, p, or the number of repetitions. Compare exact binomial probabilities with empirical frequencies.

Ready to run.

The simulation approaches the exact mass function as repetitions increase, but finite samples still fluctuate around it.

Before Choosing a Binary Distribution

Use Bernoulli for one binary outcome and binomial for the count across a fixed number of independent, equal-probability Bernoulli trials. State which outcome is encoded as one, distinguish a count from a proportion, and verify the repeated-trial assumptions rather than relying only on the observed range.

The next lesson extends the same one-trial-versus-count distinction from two outcomes to any finite number of categories.

Review

Not marked done.