Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Before going on to the topic, let us understand random variables. A random variable, usually written as X. Random variable, is a variable whose possible values are numerical outcomes of a random phenomenon. The binomial random variable is a special type of discrete random variable.
Before going on to the topic, let us understand random variables. A random variable, usually written X, is a variable whose possible values are numerical outcomes of a random phenomenon.
Definition
In statistics and probability, the binomial distribution with parameters p and n is the discrete probability distribution of a sequence of successes of n independent experiments. Each is asking a yes or no question. Each has its Boolean-valued outcome, where the probability of success is p, and the probability of failure is q (q = 1-p). A single success/failure experiment is also called a Bernoulli trial or Bernoulli experiment. A sequence of outcomes is called a Bernoulli process; the binomial distribution is a Bernoulli distribution for a single trial.
Properties of the binomial random variable
There are a finite number of trials in a binomial experiment(let the number of trials be n).
All the trials must be independent.
Each trial has exactly two possible outcomes, i.e., success or failure.
The probability of success is constant for all the trials, i.e., p.
The number of successes(r) in n successive independent trials of a Bernoulli experiment is called a binomial random variable.
Mean and Variance
If X is a binomially distributed random variable, where p is the probability of success and q is the probability of failure and n is the number of trials. Mean of X = E(X) = np Variance of X = Var(X) = npq
Probability mass function
The probability of achieving r success in n trials will be(if success is r, then failures will be n-r): Probability: pr (1 - p)n - r
The total number of ways to achieve “r” successes is: nCr = n! / ((n - r)!*r!)
Therefore, the probability mass function or total probability of achieving r successes and n-r failures is: p.m.f = (n! / ((n - r)!*r!))*(pr (1 - p)n - r)
Example
Let us understand the probability mass function by a small example. Consider a coin-tossing experiment of a biased coin if the coin is tossed 10 times and the probability of getting head is 0.58. Suppose getting head is considered a success then, create the binomial distribution table that will contain the probability of r successes for each possible value of r.
r
0
1
2
3
4
5
6
7
8
9
10
P(r)
0.00017
0.0023
0.0146
0.0539
0.1304
0.2161
0.2487
0.1963
0.1016
0.0311
0.0043
Let us use scipy and matplotlib library to draw the table and to plot the distribution.
Code
from scipy.stats import binom import matplotlib.pyplot as plt
n = 10 p = 0.58 # defining the list of r values r_values = list(range(n + 1)) # obtaining the mean and variance mean, var = binom.stats(n, p)
# list of pmf values dist = [binom.pmf(r, n, p) for r in r_values ]
# printing the table print("r\tp(r)") for i in range(n + 1): print(str(r_values[i]) + "\t" + str(dist[i])) # printing mean and variance print("mean = "+str(mean)) print("variance = "+str(var))
# plotting the distribution plt.scatter(r_values, dist, color = "red")
Output
r p(r) 00.00017080198121677845 10.002358694026326941 20.014657598592174546 30.0539771884664206 40.13044487212718306 50.21616578809647477 60.24876221646022886 70.19630215720671115 80.10165647426776102 90.031196166706508714 100.004308042068994052 mean = 5.8 variance = 2.436
When the probability of success and failure are equal, then the binomial distribution will be a normal distribution. (change the value of p to 0.5 and plot the graph)
Cumulative distribution function
For a random variable X, X's cumulative distribution function (CDF) calculates the SUM of the probabilities for 0, 1, 2, ... up to the value of X. It calculates the probability of obtaining at most X success in n trials.
Let us take an illustrative example(same question taken for pmf) to plot cumulative distribution function. p = 0.58 n = 10
Code
from scipy.stats import binom import matplotlib.pyplot as plt
n = 10 p = 0.58 # defining the list of r values r_values = list(range(n + 1))
# list of pmf values dist = [binom.cdf(r, n, p) for r in r_values ]
# printing the table print("r\tcdf") for i in range(n + 1): print(str(r_values[i]) + "\t" + str(dist[i]))
# plotting the distribution plt.scatter(r_values, dist, color = "red")
A coin is tossed 7 times. What is the probability of getting exactly 5 heads? If the coin is unbiased. Solution: n = 7 r = 5 p = 0.5 q = 0.5 Therefore, the probability of getting exactly 5 heads will be: = 7C5.(1/2)5.(1/2)2 = 21 / 128 = 0.164
A unbiased coin is tossed n times. The probability of occurring head six times is the same as occurring head comes eight times, then find the value of n. Solution: P(6) = P(8) From the given condition, we can write nC6.(1/2)6.(1/2)n - 6 = nC8.(1/2)8.(1/2)n - 8 nC6.(1/2)n = nC8.(1/2)n nC6 = nC8 6 = n - 8 n = 14 Therefore, the value of n is 14
With a 5/7 probability, a person can achieve his target. Total 2 chances are given to a person. What is the total probability that a person can achieve a target at least once? Solution: p = 5/7 q = 2/7 n = 2 Probability of achieving target at least once = P(1) + P(2) = 2C1.(5/7)1.(2/7)1 + 2C2.(5/7)2.(2/7)0 = 45 / 49 = 0.9183 Therefore, the probability of achieving the target is 0.9183
Frequently Asked Questions
What does the binomial distribution depend on?
The binomial distribution is calculated by multiplying the probability of success raised to the power of the number of successes and the probability of failure raised to the power of the difference between the number of successes and the number of trials.
How is the binomial distribution used in real life?
Many instances of binomial distributions can be found in real life. For example, if a new drug is introduced to cure a disease, it either cures the disease (it's successful) or doesn't cure it (a failure). If you purchase a lottery ticket, you're either going to win money, or you aren't.
Which random variables are not binomial?
The random variables which do not have exactly 2 outcomes are not binomial random variables.
What is an example of the binomial experiment?
A binomial experiment is an experiment where you have a fixed number of independent trials with only have two outcomes.
Conclusion
In this article, we have discussed:
Definition and properties of binomial distribution
Mean and variance of binomial distribution
Plotting the binomial distributions p.m.f
The cumulative distribution function of binomial distribution
Want to learn more about Machine Learning? Here is an excellent course that can guide you in learning.