9.3: The Bernoulli and Binomial Random Variables
In this section, we will discuss two other important random variables - the Bernoulli random variable and the Binomial random variable. As usual, we will use our framework for introducing random variables by first defining the pmf or cdf, then by understanding what the random variable models, and then proving our interpretation is correct.
Definition: A random variable \(X\) whose probability mass function is given by
\[f(x) = P(X = x) =
\begin{cases}
1-p & \text{if} ~ x = 0, \\
p & \text{if} ~ x = 1, \\
0 & \text{otherwise} \\
\end{cases} = \begin{cases}
p^x (1-p)^{1-x} & \text{if} ~ x = 0, 1 \\
0 & \text{otherwise} \\
\end{cases} \]
is called a Bernoulli Random Variable with parameter \(p\) and we write \( X \sim Bern(p) \).
Suppose an experiment is to be performed with the following characteristics:
- The experiment can be thought of as consisting of one and only one trial.
- The trial may result in one of two outcomes where we think of one outcome as being a "success" while the other outcome is labeled as a "failure".
- The probability of success is \(p\) (and hence the probability of failure is \(1-p\) ).
- \(X\) models the number of successes.
Then \(X \sim Bern(p)\).
To summarize, the Bernoulli random variable models the number of successes when we perform one and only trial.
We now argue that the conditions outlined above yields the Bernoulli random variable.
Theorem: Suppose an experiment is to be performed with the following characteristics:
- The experiment consists of one and only one trial.
- The trial may result in either a success or a failure.
- The probability of success is \(p\) and the probability of failure is \(1-p\).
- \(X\) models the number of successes.
Then \(X \sim Bern(p)\).
- Proof:
-
We now derive the probability mass function of \(X\). First consider the possible values of \(X\). Suppose we are conducting one and only one trial. By assumption, this trial may result either in a success or a failure. If we have a success, then the number of successes is equal to 1 and so \(X = 1\). On the other hand, if the trial results in a failure, then the number of successes we have is 0 and so \(X = 0 \). Thus, \(X: 0 , 1\). Allow us to now find the probability associated to each value.
\( P(X=0) = P(\text{failure}) = 1-p \) and similarly, \( P(X=1) = P(\text{failure}) = p \). Hence, \[f(x) = P(X = x) =
\begin{cases}
1-p & \text{if} ~ x = 0, \\
p & \text{if} ~ x = 1, \\
0 & \text{otherwise} \\
\end{cases} = \begin{cases}
p^x (1-p)^{1-x} & \text{if} ~ x = 0, 1 \\
0 & \text{otherwise} \\
\end{cases} \nonumber\ \] which completes the derivation.
Suppose that the probability that a single seed will germinate is 0.8. If \(X\) models the number of successes, then \(X\) is a Bernoulli Random Variable with parameter 0.8 because
- There is one and only trial (where for us, a trial is planting a seed).
- That trial can either result in one of two possible outcomes. We can think of the seed germinating as a success and the seed not germinating as a failure.
- The probability of success is 0.8 and the probability of failure is 0.2.
- \(X\) models the number of successes.
Hence, we write \( X \sim Bern(0.8) \). That is,
\[
f(x) = P(X = x) =
\begin{cases}
0.2 & \text{if} ~ x = 0, \\
0.8 & \text{if} ~ x = 1, \\
0 & \text{otherwise} \\
\end{cases} \nonumber\ \]
Suppose an experiment involves drawing a single card from a deck of 52. If \(X\) models the number of aces drawn then \(X \sim Bern(4/52)\). That is,
\[
f(x) = P(X = x) =
\begin{cases}
48/52 & \text{if} ~ x = 0, \\
4/52 & \text{if} ~ x = 1, \\
0 & \text{otherwise} \\
\end{cases} \nonumber\ \]
Suppose a company produces light bulbs and there is a 1\% chance any light bulb will be defective. If we buy a single light bulb, and \(X\) models the number of defective light bulbs, then \(X \sim Bern(0.01)\). That is,
\[
f(x) = P(X = x) =
\begin{cases}
0.99 & \text{if} ~ x = 0, \\
0.01 & \text{if} ~ x = 1, \\
0 & \text{otherwise} \\
\end{cases} \nonumber\ \]
Suppose an experiment involves flipping a fair coin once. If \(X\) models the number of heads obtained, then find the distribution of \(X\).
- Answer
-
\(X \sim Bern(0.5)\).
Suppose a medical trial consists of administering a drug to a single patient and then seeing if the drug is a success (meaning beneficial) for that patient or if the drug is a failure (meaning non-beneficial) for that patient. The probability the drug is successful for any patient is 0.75. Let \(X\) model the number of patients for which the drug is successful. Find the distribution of \(X\).
- Answer
-
\(X \sim Bern(0.75)\).
We now present the expected value, variance, and cumulative distribution function for the Bernoulli random variable.
Theorem: If \(X \sim Bern(p)\) then
\begin{align*} \mathbb{E}[X] &= p \\ \mathbb{V}ar[X] &= p(1-p) \end{align*}
Additionally, the cumulative distribution function is given by \[F(x) = P(X \leq x) =
\begin{cases}
0 & \text{if} ~ x < 0, \\
1-p & \text{if} ~ 0 \leq x < 1, \\
1 & \text{if} ~ x \geq 1 \\
\end{cases} \]
Allow us to modify Example 9.3.5. What if instead of administering the drug to one and only patient and modeling the number of resulting successes, we instead administered the drug to five patients and wished to model the number of successes. What would this look like? More generally, we are asking if instead of having one trial, we performed many independent trials, say \(n\) of them and wished to model the number of successes by a random variable \(X\). In such a case, what would the probability mass function of \(X\) look like? Clearly \(X\) is no longer Bernoulli since it is possible for the number of successes to be \(2\) or \(3\) or \( \ldots \) \(n\).
It would be nice to have a random variable which models the number of successes among \(n\) independent trials. The above scenario calls on us to use another brand name random variable which an extension of the Bernoulli. This random variable is the Binomial random variable.
Definition: A random variable \(X\) whose probability mass function is given by
\[f(x) = P(X = x) = \begin{cases}
\binom{n}{x} p^x (1-p)^{n-x} & \text{if} ~ x = 0, 1, 2, \ldots, n \\
0 & \text{otherwise} \\
\end{cases} \]
is called a Binomial random variable with parameters \(n\) and \(p\) and we write \( X \sim Bin(n,p) \).
Suppose an experiment is to be performed with the following characteristics:
- The experiment can be thought of as consisting of \(n\) independent trials.
- The trial may result in one of two outcomes where we think of one outcome as being a "success" while the other outcome is labeled as a "failure".
- The probability of success is \(p\) (and hence the probability of failure is \(1-p\) ).
- \(X\) models the total number of successes.
Then \(X \sim Bin(n,p)\).
To summarize, the Binomial random variable models the total number of successes among \(n\) independent trials.
We now argue that the conditions outlined above yields the Bernoulli random variable.
Theorem: Suppose an experiment is to be performed with the following characteristics:
- The experiment can be thought of as consisting of \(n\) independent trials.
- The trial may result in one of two outcomes where we think of one outcome as being a "success" while the other outcome is labeled as a "failure".
- The probability of success is \(p\) (and hence the probability of failure is \(1-p\) ).
- \(X\) models the total number of successes.
Then \(X \sim Bin(n,p)\).
- Proof:
-
We already did this! This was answered as a homework exercise.
Allow us to reconsider the following example from a previous section: a sequence of five independent trials are to be performed. Each trial consists of administering a drug to a patient and then seeing if the drug is a success (meaning beneficial) for that patient or if the drug is a failure (meaning non-beneficial) for that patient. The probability the drug is successful for any patient is 0.75. Find the probability that the drug is successful for at least one patient.
- Answer
-
We will answer this question from the point of view of random variables. In this question, we are interested in modeling the number of successes that occurs and so let \(X\) model the number of successes among the five independent trials. Notice that
- The experiment can be thought of as consisting of 5 independent trials.
- Each trial either results in a success or failure.
- The probability of success on any trial is 0.75 (and hence the probability of failure of 0.25).
- \(X\) models the total number of successes.
Then \(X \sim Bin(5, 0.75)\). That is,
\[
f(x) = P(X = x) =
\begin{cases}
\binom{5}{x}0.75^x (0.25)^{5-x} & \text{if} ~ x = 0, 1, 2, 3, 4, 5 \\
0 & \text{otherwise} \\
\end{cases}
\]
Then \(P(\text{drug is successful for at least one patient}) = P(X \geq 1) = 1 - P(X < 1) = 1 - P(X=0) = 1 - f(0) = 1 - \binom{5}{0}0.75^0 0.25^5 = 1 - 0.25^5 \approx 0.9990 \nonumber\ \).Knowing the appropriate calculator commands will be useful for future problems. Suppose \(X \sim Bin(n,p)\)and let \( k \) be in the support of \(X\). Then
- \(f(k) = P(X = k) = \binom{n}{k}p^k (1-p)^{n-k} = binompdf(n,p,k)\).
- \(F(k) = P(X \leq k) = \binom{n}{0}p^0 (1-p)^{n} + \binom{n}{1}p^1 (1-p)^{n-1} + \binom{n}{2}p^2 (1-p)^{n-2} + \ldots + \binom{n}{k}p^k (1-p)^{n-k} = binomcdf(n,p,k)\)
Note that we click \( 2^{nd}\) followed by Vars/Distribution on your calculator and scroll down to the appropriate command.
Hence, alternatively, we can write \(P(\text{drug is successful for at least one patient}) = P(X \geq 1) = 1 - P(X < 1) = 1 - P(X=0) = 1 - binompdf(5, 0.75, 0) \approx 0.9990 \nonumber\ \).
Allow us to reconsider the following example from a previous section: a sequence of five independent trials are to be performed. Each trial consists of administering a drug to a patient and then seeing if the drug is a success (meaning beneficial) for that patient or if the drug is a failure (meaning non-beneficial) for that patient. The probability the drug is successful for any patient is 0.75. Find the probability that exactly three successes occur.
- Answer
-
We will answer this question from the point of view of random variables. In this question, we are interested in modeling the number of successes that occurs and so let \(X\) model the number of successes among the five independent trials. Then \(X \sim Bin(5, 0.75)\). That is,
\[
f(x) = P(X = x) =
\begin{cases}
\binom{5}{x}0.75^x (0.25)^{5-x} & \text{if} ~ x = 0, 1, 2, 3, 4, 5 \\
0 & \text{otherwise} \\
\end{cases}
\]
Then \(P(\text{drug is successful for three patients}) = P(X = 3) = f(3) = \binom{5}{3}0.75^3 0.25^2 = \approx 0.2637 \nonumber\ \) or alternatively, \(P(\text{drug is successful for three patients}) = P(X = 3) = binompdf(5, 0.75, 3) = \approx 0.2637 \nonumber\ \).
Suppose an experiment involves planting ten seeds and checking to see how many seeds germinate. According to the manufacturer, there is a 80\% chance a seed will germinate. If the growth of the seeds are independent of each other, find the probability that exactly 7 seeds will germinate.
- Answer
-
Let \(X\) model the number of seeds that germinate. Notice that,
- The experiment can be thought of as consisting of 10 independent trials where a trial is planting a seed.
- That trial can either result in one of two possible outcomes. We can think of the seed germinating as a success and the seed not germinating as a failure.
- The probability of success is 0.8 and the probability of failure is 0.2.
- \(X\) models the number of successes.
Hence, \(X \sim Bin(10.8)\). That is,
\[
f(x) = P(X = x) =
\begin{cases}
\binom{10}{x}0.8^x (0.2)^{10-x} & \text{if} ~ x = 0, 1, 2, 3, \ldots, 10 \\
0 & \text{otherwise} \\
\end{cases}
\]
Hence \(P(\text{exactly 7 seeds will germinate}) = P(X=7) = f(7) = \binom{10}{7}0.8^7 (0.2)^{3} \approx 0.2013 = 20.13\% \) or alternatively \(P(\text{exactly 7 seeds will germinate}) = P(X=7) = binompdf(10, 0.8, 7) \approx 0.2013 = 20.13\% \)
It is known that light bulbs produced by a certain company will be defective with probability 0.01 independently of one another. The company sells the light bulbs in packs of 15 and states at most, one of the fifteen bulbs will be defective. If more than 1 bulb is defective, then the company offers a money back guarantee. Suppose you buy a pack of light bulbs. What is the probability that your pack will be eligible for the money back guarantee?
- Answer
-
Let \(X\) model the number of defective light bulbs. In order for the pack to be eligible for the money back guarantee, it means that we have more than 1 defective light bulb. So we must find \(P(X > 1).
1) We have a total of 15 independent trials where we can think of each trial as examining each light bulb and checking to see if it is defective or working.
2) Each trial either results in a success (defective) or failure (working).
3) The probability of success on each trial is 0.01 and the probability of failure on each trial is 0.99.
4) \(X\) models the total number of successes.
Hence \(X \sim Bin(15, 0.01)\). That is,
\[
f(x) = P(X = x) =
\begin{cases}
\binom{15}{x}0.01^x (0.99)^{15-x} & \text{if} ~ x = 0, 1, 2, 3, \ldots, 15 \\
0 & \text{otherwise} \\
\end{cases}
\]
So
\begin{align*}
P(X > 1) &= P(X=2) + P(X=3) + P(X=4) + \ldots + P(X=15) \\
&= 1 - P(X \leq 1) \\
&= 1 - [P( \{ X=0 \} \cup \{ X=1 \}] \\
&= 1 -[ P(X=0) + P(X=1) ] \\
&= 1 - \bigg[\binom{15}{0}0.01^0 (0.99)^{15} + \binom{15}{1}0.01^1 (0.99)^{14} \bigg] \\
&= 0.0096297734
\end{align*}Alternatively, we can say that \begin{align*}
P(X > 1) &= P(X=2) + P(X=3) + P(X=4) + \ldots + P(X=15) \\
&= 1 - P(X \leq 1) \\
&= 1 - [P( \{ X=0 \} \cup \{ X=1 \}] \\
&= 1 -[ binompdf(15, 0.01, 0) + binompdf(15, 0.01, 1) ] \\
&= 0.0096297734
\end{align*} or even more succinctly,begin{align*}
P(X > 1) &= P(X=2) + P(X=3) + P(X=4) + \ldots + P(X=15) \\
&= 1 - P(X \leq 1) \\
&= 1 - [P( binomcdf(15, 0.01, 1)] \\
&= 0.0096297734
\end{align*}
We now present the expected value and variance for the Bernoulli random variable.
Theorem: If \(X \sim Bin(n,p)\) then
\begin{align*} \mathbb{E}[X] &= np \\ \mathbb{V}ar[X] &= np(1-p) \end{align*}