Biostatistics with R

Bernoulli trial

A Bernoulli Experiment is a random experiment which results in one of the two possible outcomes that are mutually exclusive and mutually exhaustive .


The classical example of Bernoulli trial is a coin toss . A single coin toss has two possible outcomes namely the head and the tail. These two outcomes are mutually exclusive since only one of them can result in a trial. They are mutually exhaustive because there is no third outcome.


While describing a Bernoulli trial, any one of the two possible outcomes can be conveniently designated as "success" and the other one as "failure". If \( p \) is the probability of "success", then \( 1-p \) will be the probability of "failure". Since these two outcomes are mutually exhaustive, their probabilites should add up to 1, which is the case here.

For example, in the case of a coin toss experiment, if "head" is designated as success, the probability of success \( \small{p = \dfrac{1}{2} }\), and the probability of "failure"(tail) is \(\small{ 1-p = 1-\dfrac{1}{2} = \dfrac{1}{2} }\).


When a Bernoulli experiment is repeated many times independently such that the probability of success (and hence the probability of failure) remains the same for all the experiments, they constitute a sequence of Bernoulli trials. Many real life problems in statistics can be viewed as Bernoulli trials, as shown below:

  • Suppose we toss 8 coins and observed 5 heads(say,"success") and 3 tails("failures"). This experiment ccan be viewed as eight Bernoulli trials, each with a probability of success \( \small{p = \dfrac{1}{2} }\), and probability of failure \(\small{ 1-p = \dfrac{1}{2} }\).

  • In a hospital, a particulat type of operation has 95% chance of success. On a given day, 10 operations were performed. This can be viewed as 10 Bernoulli trials, with each trial having a probability of success \( \small{p=0.95}\), and a probability of failure \(\small{1-p = 0.05}\)

  • Single throw of a dice has six possible outcomes that are mutually exclusive and mutually exhaustive, and cannot be considered a Bernoulli trial. However, if we designate one outcome, say 3 as "success" and any other outcome (ie., not having 3) as "failure", this can become a Bernoulli trial with probability of success \(\small{ p = \dfrac{1}{6} }\), and probability of failure \( \small{ 1-p = \dfrac{5}{6} }\).

Computing the probability of n Bernoulli trials

Suppose we conduct \( n\) bernoulli trials that result in the sequence of successes and failures. Out of n trials, let x of them result in a success and the remaining (n-x) result in a failure. What is the probability that this happens?

Let \(p\) be the probability of success and \(1-p\) be the probability of failure for a single trial.

Since the n trials are independent of each other, their combined probability is the product of their individual probabilities. There are x independent trials each with a probability p and (n-x) trials each with probability (1-p). If the order of successes and failures do not matter, they can separtely computed. One can write,

\( \small{P(n~trials) = [p \times p \times p \times .....(x~times) ] \times [(1-p) \times (1-p) \times .....(n-x)~~times) ] = p^x(1-p)^{n-x} }\)


We arrive at the important expression for the Bernoulli trials:


If p is the probability of success in a Bernoulli trial, then the probability for a sequence of trials resulting in a total of \(x \) successes and \((n-x)\) failures occuring in any order is given by ,


\(~~~~~~~~~~~~P_{Ber} = p^x (1-p)^{n-x} \)



Note that only the toal number of successes and failures are considered, not their order .

Suppose we throw 5 coins and consider a resulting sequence with 2 heads and three tails. The two heads and three tails can occur in many possble sequences like HHTTT, THTHT, HTTHT,.... Each one of these possible sequences can be sonsidered as a sequnce of bernoulli trials with two successes(H) and three failures(T). Each will have the same probability of \( \small{p(H)^2 (1-p(H))^{5-2} = (\dfrac{1}{2})^2 (1 - \dfrac{1}{2})^3 } \)

Example-1 : A seed company created a new variety of mango seed. Based on a large number trials, it was estimated that the probability that a seed germinate is 0.4. If we bye 20 of these seeds and plant them, what is the probability that the first 12 seeds will germinate?.

We have a sequence of first 12 germinations(success) and next 8 non-germinations (failure).

This is a Bernoulli trial with \(n=20~~\), \(x=12~~\), \(p=0.4~~\), \(1-p = 0.6~~~ \). Therefore,

\(P_{Ber} = p^x(1-p)^{n-x} = (0.4)^12 (0.6)^8 = 2.81 \times 10^{-7} \)