## 3.2 Notable Discrete Variables

In the previous section we gave a generic definition of discrete random variables and discussed the conditions that a pmf must obey. We considered the example of a biased dice and constructed a pmf for that specific example.

There are situations that often happen in practice: for instance the case of experiments with binary outcomes. For such cases random variables with specific pmfs are given a name and their properties are well known and studied.

In this section we will consider three such distributions: Bernoulli, Binomial and Poisson.

### 3.2.1 Bernoulli Distribution

Consider an experiment or a real-world system where there can only be two outcomes:

• a toss of a coin: heads or tails;

• the result of a COVID test: positive or negative;

• the status of a machine: broken or working;

By default one outcome happens with some probability, that we denote as $$\theta\in [0,1]$$ and the other with probability $$1-\theta$$.

Such a situation is in general modeled using the so-called Bernoulli distribution with parameter $$\theta$$. One outcome is associated to the number 1 (usually referred to as sucess) and the other is associated to the number 0 (usually referred to as failure). So $$P(X=1)=p(1)=\theta$$ and $$P(X=0)=p(0)=1-\theta$$.

The above pmf can be more coincisely written as $p(x)=\left\{ \begin{array}{ll} \theta^x(1-\theta)^{1-x}, & x=0,1\\ 0, & \mbox{otherwise} \end{array} \right.$ The mean and variance of the Bernoulli distribution can be easily computed as $E(X)=0\cdot(1-\theta)+ 1\cdot\theta=\theta,$ and $V(X)=(0-\theta)^2(1-\theta)+(1-\theta)^2\theta=\theta^2(1-\theta)+(1-\theta)^2\theta=\cdots = \theta(1-\theta)$

Figure 3.3 reports the pmf and the cdf of a Bernoulli random variable with parameter 0.3. Figure 3.3: PMF (left) and CDF (right) of a Bernoulli random variable with parameter 0.3

### 3.2.2 Binomial Distribution

The Bernoulli random variable is actually a very special case of the so-called Binomial random variable. Consider experiments of the type discussed for Bernoullis: coin tosses, COVID tests etc. Now suppose that instead of having just one trial, each of these experiments are repeated multiple times. Consider the following assumptions:

• each experiment is repeated $$n$$ times;

• each time there is a probability of success $$\theta$$;

• the outcome of each experiment is independent of the others.

Let’s think of tossing a coin $$n$$ times. Then we would expect that the probability of showing heads is the same for all tosses and that the result of previous tosses does not affect others. So this situation appears to meet the above assumptions and can be modeled by what we call a Binomial random variable.

Formally, the random variable $$X$$ is a Binomial random variable with parameters $$n$$ and $$\theta$$ if it denotes the number of successes of $$n$$ independent Bernoulli random variables, all with parameter $$\theta$$.

The pmf of a Binomial random variable with parameters $$n$$ and $$\theta$$ can be written as: $p(x)=\left\{ \begin{array}{ll} \binom{n}{x}\theta^{x}(1-\theta)^{n-x}, & x = 0,1,\dots,n\\ 0, & \mbox{otherwise} \end{array} \right.$ Let’s try and understand the formula by looking term by term.

• if $$X=x$$ there are $$x$$ successes and each success has probability $$\theta$$ - so $$\theta^x$$ counts the overall probability of successes

• if $$X=x$$ there are $$n-x$$ failures and each failure has probability $$1-\theta$$ - so $$(1-\theta)^{n-x}$$ counts the overall probability of failures

• failures and successes can appear according to many orders. To see this, suppose that $$x=1$$: there is only one success out of $$n$$ trials. This could have been the first attempt, the second attempt or the $$n$$-th attempt. The term $$\binom{n}{x}$$ counts all possible ways the outcome $$x$$ could have happened.

The Bernoulli distribution can be seen as a special case of the Binomial where the parameter $$n$$ is fixed to 1.

We will not show why this is the case but the expectation and the variance of the Binomial random variable with parameters $$n$$ and $$\theta$$ can be derived as $E(X)=np, \hspace{2cm} V(X)=np(1-p)$ The formulae for the Bernoulli can be retrieved by setting $$n=1$$.

Figure 3.4 shows the pmf of two Binomial distributions both with parameter $$n=10$$ and with $$\theta=0.3$$ (left) and $$\theta=0.8$$. For the case $$\theta=0.3$$ we can see that it is more likely that there are a small number of successes, whilst for $$\theta=0.8$$ a large number of successes is more likely. Figure 3.4: PMF of a Binomial random variable with parameters n = 10 and theta = 0.3 (left) and theta = 0.8 (right)

R provides a straightforward implementation of the Binomial distribution through the functions dbinom for the pmf and pbinom for the cdf. They require three arguments:

• first argument is the value at which to compute the pmf or the cdf;

• size is the parameter $$n$$ of the Binomial;

• prob is the parameter $$\theta$$ of the Binomial.

So for instance

dbinom(3, size = 10, prob = 0.5)
##  0.1171875

returns $$P(X=3)=p(3)$$ for a Binomial random variable with parameter $$n=10$$ and $$\theta = 0.5$$.

Similarly,

pbinom(8, size = 20, prob = 0.2)
##  0.9900182

returns $$P(X\leq 8) = F(8)$$ for a Binomial random variable with parameter $$n=20$$ and $$\theta = 0.2$$.

### 3.2.3 Poisson Distribution

The last class of discrete random variables we discuss is the so-called Poisson distribution. Whilst for Bernoulli and Binomial we had an interpretation of why the pmf took its specific form by associating it to independent binary experiments each with an equal probability of success, for the Poisson there is no such an interpretation.

A discrete random variable $$X$$ has a Poisson distribution with parameter $$\lambda$$ if its pmf is $p(x)=\left\{ \begin{array}{ll} \frac{e^{-\lambda}\lambda^x}{x!}, & x = 0,1,2,3,\dots\\ 0, & \mbox{otherwise} \end{array} \right.$ where $$\lambda > 0$$.

So the sample space of a Poisson random variable is the set of all non-negative integers.

One important characteristic of the Poisson distribution is that its mean and variance are equal to the parameter $$\lambda$$, that is $E(X)= V(X) = \lambda.$

Figure @ref{fig:poisson} gives an illustration of the form of the pmf of the Poisson distribution for two parameter choices: $$\lambda=1$$ (left) and $$\lambda = 4$$ (right). The x-axis is shown until $$x=10$$ but recall that the Poisson is defined over all non-negative integers. For the case $$\lambda=1$$ we can see that the outcomes 0 and 1 have the largest probability - recall that $$E(X)=0$$. For the case $$\lambda = 4$$ the outcomes $$x = 2,3,4,5$$ have the largest probability. Figure 3.5: PMF of a Poisson random variable with parameter 1 (left) and 4 (right)

R provides a straightforward implementation of the Poisson distribution through the functions dpois for the pmf and ppois for the cdf. They require three arguments:

• first argument is the value at which to compute the pmf or the cdf;

• lambda is the parameter $$\lambda$$ of the Poisson;

So for instance

dpois(3, lambda = 1)
##  0.06131324

returns $$P(X=3)=p(3)$$ for a Poisson random variable with parameter $$\lambda = 1$$.

Similarly,

ppois(8, lambda = 4)
##  0.9786366

returns $$P(X\leq 8) = F(8)$$ for a Poisson random variable with parameter $$\lambda = 4$$.

### 3.2.4 Some Examples

We next consider two examples to see in practice the use of the Binomial and Poisson distributions.

#### 3.2.4.1 Probability of Marriage

A recent survey indicated that 82% of single women aged 25 years old will be married in their lifetime. Compute

• the probability of at most 3 women will be married in a sample of 20;

• the probability of at least 90 women will be married in sample of 100;

• the probability of two or three women in a sample of 20 will never be married.

The above situation can be modeled by a Binomial random variable where the parameter $$n$$ depends on the question and $$\theta = 0.82$$.

The first question requires us to compute $$P(X\leq 3)= F(3)$$ where $$X$$ is Binomial with parameters $$n=20$$ and $$\theta =0.82$$. Using R

pbinom(3, size = 10, prob = 0.82)
##  0.0004400767

The second question requires us to compute $$P(X\geq 90)$$ where $$X$$ is a Binomial random variable with parameters $$n=100$$ and $$\theta = 0.82$$. Notice that $P(X\geq 90) = 1 - P(X< 90) = 1 - P(X\leq 89) = 1 - F(89).$ Using R

1 - pbinom(89, size = 100,  prob = 0.82)
##  0.02003866

For the third question, notice that saying two women out of 20 will never be married is equal to 18 out of 20 will be married. Therefore we need to compute $$P(X=17) + P(X=18)= p(17) + p(18)$$ where $$X$$ is a Binomial random variable with parameters $$n=20$$ and $$\theta = 0.82$$. Using R

sum(dbinom(17:18, size = 20, prob = 0.82))
##  0.4007631

A stuntman injures himself an average of three times a year. Use the Poisson probability formula to calculate the probability that he will be injured:

• 4 times a year

• Less than twice this year.

• More than three times this year.

The above situation can be modeled as a Poisson distribution $$X$$ with parameter $$\lambda = 3$$.

The first question requires us to compute $$P(X=4)$$ which using R can be computed as

dpois(4, lambda =3)
##  0.1680314

The second question requires us to compute $$P(X<2) = P(X=0)+P(X=1)= F(1)$$ which using R can be computed as

ppois(1,lambda=3)
##  0.1991483

The third question requires us to compute $$P(X>3) = 1 - P(X\leq 2) = 1 - F(2)$$ which using R can be computed as

1 - ppois(2, lambda = 3)
##  0.5768099