Tutorials › Exam ASTAM - Advanced Short-Term Actuarial Mathematics › Binomial Sampling By Bernoulli Sums

Exam ASTAM · Random Variate Generation · Tutorial 591 of 979

Binomial Sampling By Bernoulli Sums

Build a binomial simulation from independent Bernoulli indicators, then verify what the construction implies for the count’s distribution, mean, and variance.

Beginner 10 min read

What You'll Learn

  • Construct each Bernoulli trial from an independent uniform random number.
  • Combine the trial indicators to generate a binomial count.
  • Derive the binomial probability function from the Bernoulli-sum construction.
  • Obtain the count’s mean and variance using independence.
  • Diagnose how reusing a random number changes the variance.
  • Distinguish one simulated count from the distribution’s expected value.

Why Build a Binomial Count From Bernoulli Trials?

A binomial random variable counts successes in a fixed number of repeated trials. In simulation, one direct way to generate that count is to generate the outcome of every trial and add the success indicators. This construction makes the assumptions behind the binomial model visible: the number of trials is fixed, each trial has the same success probability, and the trial outcomes are independent.

For example, a hypothetical insurer might simulate how many of a fixed group of policyholders report a specified event during a period. If each policyholder has the same probability of reporting and reports are independent under the model, the number reporting can be generated as a sum of Bernoulli indicators. The same logic applies to other repeated yes-or-no outcomes.

Definition: Let \(B_1,\ldots,B_n\) be independent Bernoulli random variables with \(P(B_i=1)=p\) and \(P(B_i=0)=1-p\) for every \(i\). Their sum \(K=\sum_{i=1}^{n}B_i\) has a binomial distribution with parameters \(n\) and \(p\), written \(K\sim\operatorname{Bin}(n,p)\). Here, \(n\) is the fixed number of trials and \(p\) is the common probability of success on each trial.

The values \(B_i=1\) and \(B_i=0\) represent success and failure, respectively. “Success” is simply the outcome being counted; it need not be favorable. If the trial probabilities differ, or if the trial outcomes are dependent, the sum may still be a count but it does not generally have the binomial distribution with parameters \(n\) and a common \(p\).

The Sampling Construction

Assume that \(U_1,\ldots,U_n\) are independent random variables, each uniformly distributed on \([0,1]\). For a specified success probability \(p\), define the trial indicators by comparing each uniform value with \(p\):

$$ B_i= \begin{cases} 1, & U_i<p,\\ 0, & U_i\ge p, \end{cases} \qquad K=\sum_{i=1}^{n}B_i. $$

Since a uniform random variable falls below \(p\) with probability \(p\), each indicator is Bernoulli with success probability \(p\). Because the uniforms are independent, the indicators are independent too. Thus this construction generates \(K\sim\operatorname{Bin}(n,p)\). Using \(U_i\le p\) instead of \(U_i<p\) makes no difference to the distribution: the probability of a uniform value being exactly \(p\) is zero.

1
Specify the model.
Choose the fixed number of trials \(n\) and the common success probability \(p\), where \(0\le p\le1\).
2
Generate the trial inputs.
Generate \(n\) independent uniform values \(U_1,\ldots,U_n\).
3
Convert each value to an outcome.
Set \(B_i=1\) when \(U_i<p\), and set \(B_i=0\) otherwise.
4
Add the outcomes.
Return \(K=B_1+\cdots+B_n\), an integer from 0 through \(n\).

This is a simulation algorithm, not a way to calculate the expected count directly. A single run returns one realized integer. Repeating the algorithm produces a collection of counts whose distribution is binomial under the stated assumptions.

Distribution, Mean, and Variance

For exactly \(k\) successes, where \(k=0,1,\ldots,n\), choose which \(k\) of the \(n\) trials succeed. Each such pattern has probability \(p^k(1-p)^{n-k}\), by independence. There are \(\binom{n}{k}\) patterns, and they are mutually exclusive. Therefore:

$$ P(K=k)=\binom{n}{k}p^k(1-p)^{n-k}, \qquad k=0,1,\ldots,n. $$

The mean and variance can be derived directly from the sum rather than memorized as separate properties of the binomial distribution. A Bernoulli indicator has mean \(E[B_i]=p\). Its square equals itself, so \(E[B_i^2]=p\), and hence \(\operatorname{Var}(B_i)=p-p^2=p(1-p)\). Linearity of expectation gives the mean of the sum. Independence makes every covariance between distinct indicators zero, so the variance of the sum is the sum of their variances.

$$ E[K] =E\left[\sum_{i=1}^{n}B_i\right] =\sum_{i=1}^{n}E[B_i] =np, $$
$$ \begin{aligned} \operatorname{Var}(K) &=\operatorname{Var}\left(\sum_{i=1}^{n}B_i\right)\\ &=\sum_{i=1}^{n}\operatorname{Var}(B_i) +2\sum_{1\le i<j\le n}\operatorname{Cov}(B_i,B_j)\\ &=np(1-p). \end{aligned} $$

The independence condition is essential to the variance calculation. Equal marginal success probabilities alone do not ensure that the sum has variance \(np(1-p)\). If trials are dependent, the covariance terms may be nonzero.

Theorem: For \(K\sim\operatorname{Bin}(n,p)\), \(E[K]=np\) and \(\operatorname{Var}(K)=np(1-p)\), provided the count is formed from \(n\) independent Bernoulli trials with the same success probability \(p\). These are properties of the model, not guarantees about the count from any one simulation run.

Worked Examples

Worked Example: Turning Uniform Values Into a Count

A hypothetical model has \(n=5\) independent trials, each with success probability \(p=0.20\). One simulation run produces the uniform values \(0.08, 0.63, 0.19, 0.24, 0.91\). Generate the count of successes, and calculate its model mean, variance, and probability of exactly two successes.

Method. Use the Bernoulli-sum construction, comparing each independent uniform value with \(0.20\). This method avoids treating the expected number of successes as though it were the result of the run.

The comparisons give \(0.08<0.20\), \(0.63\ge0.20\), \(0.19<0.20\), \(0.24\ge0.20\), and \(0.91\ge0.20\). Thus the indicators are \(1,0,1,0,0\), and the simulated count is \(K=1+0+1+0+0=2\).

For the model mean, \(E[K]=np=5(0.20)=1.00\). For the variance, \(\operatorname{Var}(K)=np(1-p)=5(0.20)(0.80)=0.80\).

For exactly two successes, use the binomial probability function: \(P(K=2)=\binom{5}{2}(0.20)^2(0.80)^3=10(0.04)(0.512)=0.2048\).

The run returned two successes, while the model mean is one success. This is not a contradiction: the mean describes the distribution over repeated runs, not a required outcome in each run. The computed probability is \(0.2048\), consistent with the specified binomial model.

Worked Example: A Larger Simulated Trial Set

A hypothetical inspection study models \(n=8\) inspected components, with each component independently failing inspection with probability \(p=0.35\). A run produces the uniforms \(0.12,0.71,0.33,0.05,0.88,0.49,0.27,0.64\). Find the simulated number of failures and the model’s mean and variance.

Method. Apply the threshold \(0.35\) to each of the eight independent uniforms, then sum the indicators. The common mistake to avoid is counting values above the threshold as failures when the stated rule defines a failure by \(U_i<p\).

The values below \(0.35\) are \(0.12,0.33,0.05,\) and \(0.27\). Their indicators are 1; the other four indicators are 0. The resulting count is \(K=1+0+1+1+0+0+1+0=4\).

The mean is \(E[K]=np=8(0.35)=2.8\). The variance is \(\operatorname{Var}(K)=np(1-p)=8(0.35)(0.65)=8(0.2275)=1.82\).

The simulated value, 4, is an integer between 0 and 8, as required. It need not equal the mean of 2.8; the count is a realization, whereas 2.8 is the average across the model distribution.

Worked Example: Why Reusing One Uniform Gives the Wrong Variance

A programmer needs to simulate \(K\sim\operatorname{Bin}(6,0.25)\), but mistakenly generates one uniform value \(U\) and uses it for all six trial indicators: \(B_i=1\) if \(U<0.25\), and \(B_i=0\) otherwise. Describe the resulting count distribution and compare its mean and variance with the intended binomial model.

Method. Examine the dependence created by the shared uniform. This identifies why matching the success probability for each individual indicator is not enough to produce the correct binomial sum.

If \(U<0.25\), all six indicators equal 1 and the count is 6. If \(U\ge0.25\), all six equal 0 and the count is 0. Therefore, the flawed count is 6 with probability \(0.25\) and 0 with probability \(0.75\). Its mean is \(E[K]=6(0.25)+0(0.75)=1.5\).

Its second moment is \(E[K^2]=6^2(0.25)+0^2(0.75)=36(0.25)=9\). Thus its variance is \(\operatorname{Var}(K)=E[K^2]-E[K]^2=9-(1.5)^2=9-2.25=6.75\).

For the intended binomial model, the mean is also \(np=6(0.25)=1.5\), but its variance is \(np(1-p)=6(0.25)(0.75)=1.125\). The shared-uniform construction gives the correct marginal probability for each indicator but makes the indicators dependent; consequently the count has the wrong variance and the wrong distribution. The correction is to generate six independent uniform values. This is the dependence error the construction is designed to prevent.

Exam Traps and Practical Checks

This simulation method is aligned with the SOA Exam ASTAM (Advanced Short-Term Actuarial Mathematics) syllabus. When a problem asks for a binomial variate generated by Bernoulli sums, keep the model assumptions and the simulated outcome separate.

  • Changing the number of trials. The binomial model has a fixed \(n\). Stop after exactly \(n\) Bernoulli trials; do not continue until a chosen number of successes occurs.
  • Using different thresholds. A common \(p\) is required for the binomial model. If trial \(i\) instead has success probability \(p_i\), the indicators can still be summed, but the count is generally not binomial.
  • Reusing random inputs. A separate independent uniform input is needed for each trial. Reuse can make outcomes dependent, even when each individual indicator still has probability \(p\) of being 1.
  • Confusing a realization with a mean. The count returned by one run must be an integer from 0 to \(n\). The value \(np\) is its expected value and need not be an integer or match a particular run.
  • Misapplying the variance formula. The formula \(np(1-p)\) relies on independent trials with a common probability. Check those assumptions before using it.

As a basic implementation check, every generated count should lie between 0 and \(n\), inclusive. Across many independent runs, the sample average should tend toward \(np\), and the sample variance should tend toward \(np(1-p)\). These are long-run checks; finite simulation results will generally differ from the theoretical values.

Check Your Understanding

For each problem, use the Bernoulli-sum construction where appropriate. Answers are included for checking after you work through the steps.

  1. A model uses \(n=4\) independent trials with \(p=0.30\). The uniforms are \(0.14, 0.81, 0.29, 0.44\). Find the simulated count, mean, and variance. (Answer: \(K=2\), \(E[K]=1.2\), \(\operatorname{Var}(K)=0.84\).)
  2. For \(n=7\) and \(p=0.60\), the uniforms are \(0.09, 0.63, 0.48, 0.17, 0.91, 0.58, 0.32\). How many successes occur, and what are the model mean and variance? (Answer: \(K=5\), \(E[K]=4.2\), \(\operatorname{Var}(K)=1.68\).)
  3. A hypothetical process has ten independent trials, each with success probability \(0.10\). Find the mean, variance, and probability of no successes. (Answer: mean \(=1\), variance \(=0.9\), and \(P(K=0)=0.9^{10}=0.3487\), to four decimals.)
  4. Three independent indicators have success probabilities \(0.10\), \(0.20\), and \(0.30\), respectively. Find the mean and variance of their sum, and state whether the sum is binomial. (Answer: mean \(=0.10+0.20+0.30=0.60\); variance \(=0.10(0.90)+0.20(0.80)+0.30(0.70)=0.46\); it is not generally binomial because the success probabilities differ.)
  5. A programmer uses one shared uniform value for all four indicators intended to have success probability \(0.40\). What are the mean and variance of the resulting count, and what would the variance be for four independent trials? (Answer: shared-uniform mean \(=1.6\), shared-uniform variance \(=4^2(0.40)(0.60)=3.84\); independent-trial variance \(=4(0.40)(0.60)=0.96\).)
Clinical Biostats