Binomial Distribution: Definition and Examples

Binomial Distribution: Definition and Examples

2 mins read3.5K Views Comment
Vikram
Vikram Singh
Assistant Manager - Content
Updated on Dec 9, 2022 08:46 IST

Introduction:

A probability distribution is a function that gives the relationship between the outcome of a random variable in any random experiment and its probable values.

2022_02_feature-images_binomial.jpg

In this article, we will discuss one of the probability distributions which is commonly used in Data Science, Binomial Distribution.

To know more about Random Variable, read the article Introduction to Probability.

To know about other probability distributions, read the article Probability Distribution used in Data Science.

Table of Content:

Binomial Distribution:

A discrete probability distribution that gives the probability of only two possible outcomes in n independent trails is known as Binomial Distribution.

Example:

  • Number of Tails in flipping coin n times.
  • The number of times getting 1 on throwing a dice.

Condition of Binomial Distribution:

  • Experiment consist of n identical trials 
  • Each trial are independent
  • Each trial results in one of the two possible outcomes i.e. Success or Failure
  • The probability of success remains constant throughout the experiment

Mathematical Definition:

For any random variable X, the probability distribution function for Binomial Distribution is given by:

2022_02_formula_binomial-distribution-definition-and-formula.jpg

Example: Binomial Distribution using Python

1.

# import library
 
from scipy.stats import binom # binom: binomial distribution function
import seaborn as sns
 
# generating sample set of size 1000, having 20 trials, and probability of success = 0.5 
 
sample_set = binom.rvs(n = 20, p = 0.5, size = 1000) # binom.rvs: generate the random number
 
# plotting the binomial distribution
 
sns.distplot(sample_set, hist = False)
2022_02_example_binomial-distribution-definition-and-formula.jpg

2. Binomial distribution at different values of p

# import library
 
from scipy.stats import binom # binom: binomial distribution function
import seaborn as sns
import matplotlib.pyplot as plt
 
# plotting the binomial distribution for sample set of size 1000, having 20 trials, and different probability of success 
 
sns.distplot(binom.rvs(n = 20, p = 0.3, size = 1000), hist = False, label = 'p = 0.3')
sns.distplot(binom.rvs(n = 20, p = 0.5, size = 1000), hist = False,  label = 'p = 0.5')
sns.distplot(binom.rvs(n = 20, p = 0.8, size = 1000), hist = False, label = 'p = 0.8')
 
plt.legend()
plt.show()
2022_02_example_2_binomial-distribution-definition-and-formula.jpg

Properties of Binomial Distribution:

  • Mean = np
  • Variance = npq
  • When we increase the value of n to infinite, we get the Poisson distribution

To know more about Poisson Distribution, read the article Poisson Distribution: Definition and Example.

Bernoulli Distribution:

Bernoulli distribution is a special case of Binomial Distribution when the random experiment is done just only one time. 

Similar to binomial distribution it has only two possible outcomes:

  • Success (1)
  • Failure (0)

Note: The sum of the probability of success and failure is equal to 1.

Example: 

  • India will win the cricket world cup or not
  • You will pass the exam or not

Mathematical definition:

For any random variable n, the probability distribution function for Bernoulli Distribution is given by:

Example: 

Consider an experiment of shooting the basketball

Conclusion:

In this article, we have discussed about one of the most important probability distribution Binomial Distribution, with examples in python.

Hope this article will help in your data science and machine learning journey.

Top Trending Articles:
Data Analyst Interview Questions | Data Science Interview Questions | Machine Learning Applications | Big Data vs Machine Learning | Data Scientist vs Data Analyst | How to Become a Data Analyst | Data Science vs. Big Data vs. Data Analytics | What is Data Science | What is a Data Scientist | What is Data Analyst

About the Author
author-image
Vikram Singh
Assistant Manager - Content

Vikram has a Postgraduate degree in Applied Mathematics, with a keen interest in Data Science and Machine Learning. He has experience of 2+ years in content creation in Mathematics, Statistics, Data Science, and Mac... Read Full Bio