Hi there. In this probability and statistics post, I go over the binomial distribution.
<center><img src="https://cdn.pixabay.com/photo/2020/05/24/14/25/cube-5214498_960_720.jpg" /></center>
<center><a href="https://cdn.pixabay.com/photo/2020/05/24/14/25/cube-5214498_960_720.jpg">Pixabay Image Source</a></center>
## Success Or Failure
---
The binomial distribution is for computing probabilities for the number of successes out of a number of repeated trials. In each trial, the outcome is either a success or a failure. The concept of success and failure is defined by the experimenter(s). In a fair coin flip, flipping a heads can be considered a "success" while getting a tails is a "failure". The other way around can be done too where a tails is a "success" and a heads is a "failure".
## The Binomial Distribution
---
Let's define some variables before getting into the formula.
* Denote `X` as a binomial random variable with `n` trials with its probability of success and probability of failure in each trial.
* Denote `n` as the number of (independent Bernoulli) trials in the binomial experiment. (If n = 1 then this experiment simplifies into a single Bernoulli trial.)
* Let `p` be the probability of "success" in a trial. This probability is the same in every trial.
* Let `q` be the probability of "failure" in a trial. This probability is also the same in every trial. Some people don't use `q` for the probability of failure. They may use `1 - p` instead.
The probability of obtaining `k` successes out of `n` trials is given by:
<center>https://quicklatex.com/cache3/41/ql_a419de79738dd5de999e4311b2e3bf41_l3.png</center>
Note that https://quicklatex.com/cache3/b9/ql_db1198e49eb80f1d621083693589e5b9_l3.png = https://quicklatex.com/cache3/1a/ql_50f11ad2ce261a912954a4ca380d3d1a_l3.png. This represents the number of ways we can choose `k` objects from `n` different objects.
<center><img src="https://cdn.pixabay.com/photo/2017/10/25/22/29/bayesian-2889576_960_720.png" /></center>
<center><a href="https://cdn.pixabay.com/photo/2017/10/25/22/29/bayesian-2889576_960_720.png">Pixabay Image Source</a></center>
## Mean & Variance Of The Binomial Distribution
---
The mean of the binomial distribution is given by `np`. This is the product of the number of trials and the probability of success.
The variance for binomial distribution is given by `np(1 - p)` or `npq`. This is the product of the number of trials, the probability of success and the probability of failure.
For those interested in the proofs of obtaining the mean and variance of the binomial distribution, you can look at a resource such as [this](https://www.probabilisticworld.com/binomial-distribution-mean-variance-formulas-proof/). The proofs involves expected values, factorials, index shifting in sums, and the sum of probabilities equaling one property.
<center><img src="https://cdn.pixabay.com/photo/2018/11/17/12/27/mathematics-3821034_960_720.jpg" /></center>
<center><a href="https://cdn.pixabay.com/photo/2018/11/17/12/27/mathematics-3821034_960_720.jpg">Pixabay Image Source</a></center>
## Examples
---
**Example One - Coin Flipping**
Consider a fair coin with an equal probability of getting heads or tails. This makes the calculations easier.
The probability of getting two heads out of five flips is given by:
<center>https://quicklatex.com/cache3/62/ql_561fb4884a2a86fb38f9d29e10a52e62_l3.png</center>
There is a 31.25% chance of flipping 2 heads out of five flips. (This is the same probability for 2 tails out of 5 flips on a fair coin.)
The result from 5 choose 2 comes from the numbers of ways of choosing 2 heads from 5 coin flips.
**Example Two - Rolling A Die Multiple Times**
In this second example, consider a fair six sided die from the numbers 1 to 6 (inclusive). Each number has a 1/6 chance of showing up from a roll. The die is rolled four times. What is the probability of rolling a 2 two times out of the four rolls?
The success here is rolling a two with a probability of one-sixth. Anything other than a two is consider a "failure".
<center>https://quicklatex.com/cache3/b9/ql_2b8cc2554e9d1cbd5690fe0003cf24b9_l3.png</center>
**Example Three - Random Selection Of A Marble In A Bag With Replacement**
You select a marble at random from a bag of marbles. There are 3 red marbles, 2 green marbles and 2 blue marbles in the bag. After selecting the first marble you put it back and select a second marble at random.
What is the chance that you get 1 green marble or two green marbles in the two picks?
To obtain the answer you can compute the probability of getting one green marble and the probability of selecting two green marbles from two draws.
Here is the probability for one green marble out of two picks.
<center>https://quicklatex.com/cache3/4f/ql_accc579378eb31b5702e2bc1399acf4f_l3.png</center>
Here is the probability of selecting two green marbles from two picks.
<center>https://quicklatex.com/cache3/6d/ql_e61301aea4a70db89c157841d9deb66d_l3.png</center>
Combining these probabilities together gives the probability of selecting one green marble or two green from two picks. The answer here is 24/49 which is about 48.98%.
Note that it is important that we have sampling with replacement to keep the probability of "success" the same in each trial/draw. If there was sampling without replacement where the marble is not put back after the first draw then that is a different case.
<center><img src="https://cdn.pixabay.com/photo/2013/10/22/10/06/blue-199261_960_720.jpg" /></center>
<center><a href="https://cdn.pixabay.com/photo/2013/10/22/10/06/blue-199261_960_720.jpg">Pixabay Image Source</a></center>
<center>Thank you for reading.</center>
Posted with [STEMGeeks](https://stemgeeks.net)