Ten days of statistics (5) - Binomial distribution

Binomial experiment

A binomial experiment is an experiment that is:

  • The experiment consists of nn repeated trials
  • The trials are independent
  • The outcome of each trial is either success or failure

The sample space of a binomial experiment only has 2 points, 1 (success) and 0 (failure). Let p(x)p(x) be the probability of an experiment ending with result xx

p(x)={1k if x = 0 k if x = 1 0 otherwise p(x) = \begin{cases} 1-k & \text{ if x = 0 } \\ k & \text{ if x = 1 } \\ 0 & \text{ otherwise } \end{cases}

Binomial distribution

We define a binomial process to be a binomial experiment meeting the following conditions:

  • The number of successes is xx.
  • The total number of trials is nn.
  • The probability of success of 11 trial is pp.

Let b(x,n,p)b(x,n,p) is the probability of having exact xx successes out of nn trials. Then we have

b(x,n,p)=C(nx)×px×(1p)nxb(x, n, p) = C \binom{n}{x} \times p^x \times (1-p)^{n-x}

Note: C(nr)=n!÷(r!×(nr)!)C\binom{n}{r} = n! \div (r! \times (n-r)!)


Toss a coin 10 times. Let’s find the following probabilities:

  • Getting 5 heads
  • Getting at least 5 heads
  • Getting at most 5 heads

Using binomial distribution formular, we have

b(5,10,0.5)=0.24609375b(5, 10, 0.5) = 0.24609375

We have 25%\approx 25\% chance of getting exact 5 heads.

x=510b(x,10,0.5)=0.623046875\sum_{x=5}^{10} b(x,10,0.5) = 0.623046875

We have 62%\approx 62\% chance of getting at least 5 heads

x=05b(x,10,0.5)=0.623046875\sum_{x=0}^5 b(x, 10, 0.5) = 0.623046875

We also have 62%\approx 62\% chance of getting at most 5 heads

Negative binomial experiment

A negative binomial experiment is an experiment that is:

  • The probability of success of 11 trial is pp
  • The trials continue until xx successes are observed
  • The total number of trials is not fixed

Note: the different between negative binomial experiment and binomial experiment is on the interest. Negative version only interest in getting exact xx successes, normal version interest in performing exact nn trials.

Negative binomial distribution

Formally speaking, let b(x,n,p)b^*(x, n, p) be the probability of having

  • Exact x1x-1 successes after n1n-1 trials
  • Exact xx successes after nn trials
b(x,n,p)=C(n1x1)×px×(1p)nxb^*(x, n, p) = C \binom{n-1}{x-1} \times p^x \times (1-p)^{n-x}

Geometric distribution

The geometric distribution is a special case of the negative binomial distribution that deals with the number of trials required to get a success (i.e. counting the number of failures before the first success).

g(n,p)=p×(1p)n1g(n,p) = p \times (1-p)^{n-1}


Vova’s family lives in Russia where the weather is cold. The chance for Vova’s wife to give birth to a boy is 30%. What is the probability that Vova have his first son at his fifth child?

For this experiment, n=5,p=0.3n = 5, p = 0.3, we have g(5,0.3)=0.3×0.74=0.07203g(5, 0.3) = 0.3 \times 0.7^4 = 0.07203. So Vova has 7%\approx 7\% of having his first son at his fifth child.


Hackerrank has some exercises for you to test your knowledge:

Next lesson: Poisson & normal distribution

That's all! Thank you for reading all the way here 😊

Made with love using Svelte, Three.js, TailwindCSS