Comprehensive Guide on Binomial Distribution
Start your free 7-days trial now!
Before we dive into the formal definition of the binomial distribution, we will first go through a simple motivating example and try to derive the binomial distribution ourselves.
Motivating example of the binomial distribution
Suppose we toss an unfair coin three times. The probability that the coin lands on heads is
Solution. Let's define the random variable
Let's understand how these probabilities were calculated.
The key here is to realize that each of these outcomes occurs with the same probability.
Therefore, instead of computing all of these probabilities, we can simply compute one probability and multiply it by the number of ways to obtain the outcome. In this case, the number of ways of obtaining
If you are unfamiliar with the concept of combinations, please refer to our comprehensive guide here.
Similarly, for
Let's now go back to and express the green multiples using combinations:
Can you see that there is a pattern here? In fact, we can compute each probability like so:
Here:
is the number of trials. is the probability of success. is the probability of failure. is the number of successes we observe.
replacing the number of trials (
) with .the probability of success (
) with .the probability of failure by (
) with .
Doing so will give us the famous binomial distribution below.
Probability mass function of binomial distribution
A random variable
Where
is the number of trials. is the probability of success.
Note that we often use the notation
Assumptions of binomial distribution
From our motivating example, it should be clear that the following conditions must be satisfied for the binomial distribution to be appropriate:
for each trial, there are only
outcomes - either success or failure.the number of trials
is fixed.each trial has the same probability of success
. For instance, each time we toss a coin, the probability of getting a heads should always be the same.each trial is independent, which means that the result of one trial does not affect the result of another. For instance, obtaining a heads in the current trial should not affect the probability of the outcome of the next coin trial.
Whenever these assumptions are satisfied, the experiment is called a binomial experiment. A single trial of a binomial experiment is called a Bernoulli trial. We will later look at Bernoulli random variables, which are special cases of the binomial random variables with number of trials
Rolling a dice
Suppose we roll a fair dice
Solution. Let's define the random variable
each trial has either
outcomes - either or not a . You may think that a dice roll has outcomes, but we are only concerned with the binary outcome of either or not .the number of trials is fixed at
.each trial has the same probability of success,
.the trials are independent since the outcome of the current roll does not affect the outcome of the next roll.
Since the conditions of a binomial experiment are satisfied,
The probability of rolling a
We show the binomial probability mass function

We can see that the probability is indeed roughly
Case when binomial distribution does not apply
Suppose we have a bag that contains 3 red balls and 1 green ball. We randomly draw two balls in succession without replacement. If we let random variable
Solution. Since we are not putting the ball back in for every trial, the probability of success (getting a red ball) changes. For instance, suppose we wanted to compute the probability of drawing two red balls. The probability of getting a red ball in the first draw is
This does not align with our formula for binomial distribution. In particular, this scenario violates the assumption of the binomial distribution that each trial is independent. Note that if the balls are drawn with replacement, that is, we put the ball back into the bag after each draw, then
The Bernoulli distribution is a special case of the Binomial distribution where the number of trials
Let's briefly discuss the properties of Bernoulli random variables as they will come in handy when deriving properties of Binomial random variables.
Bernoulli random variables
A random variable
Where
Intuition. The outcome of a Bernoulli random variable is either
Here are two examples of Bernoulli random variables:
suppose we toss a fair coin once. If
is a random variable such that if heads (success) and if tails (failure), then .suppose we roll a fair dice once. If
is a random variable such that if the outcome is one or two (success) and otherwise (failure), then .
The probability mass function of the two examples are as follows:
![]() | ![]() |
Note that if we assume the bin widths to be one, the total area of the bins would add up to one!
Expected value and variance of Bernoulli random variables
If
Proof. Let's derive
To derive variance
We already know what
Substituting
This completes the proof.
Now, let's get back to exploring the properties of binomial random variables!
Expected value and variance of a binomial random variable
The expected value and variance of a binomial random variable
Proof. Perhaps the simplest and the most elegant way to derive the expected value and variance of a binomial random variable
For instance, suppose we tossed a fair coin
Let's go back to the general case when
Taking the expected value of both sides and using the linearity of expected values:
We have already provenlink earlier that the expected value of a Bernoulli random variable
Plugging this into
To derive the variance of our Binomial random variable
Because
We have previously shownlink that the variance of a Bernoulli random variable
Plugging this into
This completes the proof.
Effects of parameters on the shape of the distribution
Increasing the sample size
Increasing the sample size
![]() | ![]() | ![]() |
Here, the probability of success is fixed at
Increasing probability of success
Increasing the probability of success
![]() | ![]() | ![]() |
Here, the sample size is fixed at
Working with binomial random variables using Python
Computing the binomial probability mass function
Recall the following example question from earlier:
Suppose we roll a fair dice
We can define a binomial random variable
We can also use a statistical library in Python called SciPy to easily compute the value of the binomial probability mass function:
filter_none
Copy
from scipy.stats import binom
n = 3p = (1/6)x = 1binom.pmf(x, n, p)
0.3472222222222223
Notice how this aligns with our hand-calculated result!
Drawing the binomial probability mass function
Consider the probability mass function of
We can call the binom.pmf(~)
function for all the possible values of
filter_none
Copy
import matplotlib.pyplot as plt
n = 3p = (1/6)xs = list(range(n+1)) # [0,1,2,3]# Calculate the pmf values and store in a listpmfs = binom.pmf(xs, n, p)# Plotting a bar chart with Matplotlibplt.bar(xs, pmfs)plt.xlabel('$x$')plt.ylabel('$p(x)$')plt.show()
This generates the following plot:
