## Random variables

The process of drawing a sample randomly is a random experiment and any variable measured in the sample is a random variable because the values taken by the variable in the individuals of the sample are a matter of chance.

Definition - Random variable. A random variable $X$ is a function that maps every element of the sample space of a random experiment to a real number.

The set of values that the variable can assume is called the range and is represented by $\mbox{Ran}(X)$.

In essence, a random variable is a variable whose values come from a random experiment, and every value has a probability of occurrence.

Example. The variable $X$ that measures the outcome of rolling a dice is a random variable and its range is $\mbox{Ran}(X)={1,2,3,4,5,6}$.

### Types of random variables

There are two types of random variables:

• Discrete. They take isolated values, and their range is numerable. Example. Number of children of a family, number of smoked cigarettes, number of subjects passed, etc.

• Continuous. They can take any value in a real interval, and their range is non-numerable. Example. Weight, height, age, cholesterol level, etc.

The way of modelling each type of variable is different. In this chapter we are going to study how to model discrete variables.

## Probability distribution of a discrete random variable

As values of a discrete random variable are linked to the elementary events of a random experiment, every value has a probability.

Definition - Probability function. The probability function of a discrete random variable $X$ is the function $f(x)$ that maps every value $x_i$ of the variable to its probability

We can also accumulate probabilities the same way that we accumulated sample frequencies.

Definition - Distribution function. The distribution function of a discrete random variable $X$ is the function $F(x)$ that maps every value $x_i$ of the variable to the probability of having a value less than or equal to $x_i$

The range of a discrete random variable and its probability function is known as probability distribution of the variable, and it is usually presented in a table

The same way that the sample frequency table shows the distribution of values of a variable in the sample, the probability distribution of a discrete random variable shows the distribution of values in the whole population.

Example. Let $X$ be the discrete random variable that measures the number of heads after tossing two coins. The probability tree of the random experiment is

According to this, the probability distribution of $X$ is

### Population statistics

The same way we use sample statistics to describe the sample frequency distribution of a variable, we use population statistics to describe the probability distribution of a random variable in the whole population.

The population statistics definition is analogous to the sample statistics definition, but using probabilities instead of relative frequencies.

The most important are 1:

• Mean:
• Variance:
• Standard deviation:

Example. In the random experiment of tossing two coins the probability distribution is

The main population statistics are

### Discrete probability distribution models

According to the type of experiment where the random variable is measured, there are different probability distributions models. The most common are

• Discrete uniform
• Binomial
• Poisson

## Discrete uniform distribution $U(a,b)$

When all the values of a random variable $X$ have equal probability, the probability distribution of $X$ is uniform.

Definition - Discrete uniform distribution $U(a,b)$. A discrete random variable $X$ follows a discrete uniform distribution model with parameters $a$ and $b$, noted $X\sim U(a,b)$, if its range is $\mbox{Ran}(X) = {a, a+1, \ldots,b}$ and its probability function is

Observe that $a$ and $b$ are the minimum and the maximum of the range respectively.

The mean and the variance are

Example. The variable that measures the outcome of rolling a dice follows a discrete uniform distribution model $U(1,6)$.

## Binomial distribution $B(n,p)$

Usually the binomial distribution corresponds to a variable measured in a random experiment with the following features:

• The experiment consist in a sequence of $n$ repetitions of the same trial.
• Each trial is repeated in identical conditions and produces two possible outcomes known as Success or Failure.
• The trials are independent.
• The probability of Success is the same in all the trials and is $P(\mbox{Success})=p$.

Under these conditions, the discrete random variable $X$ that measures the number of successes in the $n$ trials follows a binomial distribution model with parameters $n$ and $p$.

Definition - Binomial distribution $(B(n,p)$. A discrete random variable $X$ follows a binomial distribution model with parameters $n$ and $p$, noted $X\sim B(n,p)$, if its range is $\mbox{Ran}(X) = {0,1,\ldots,n}$ and its probability function is

Observe that $n$ is known as the number of repetitions of a trial and $p$ is known as the probability of Success in every repetition.

The mean and the variance are

Example. The variable that measures the number of heads after tossing 10 coins follows a binomial distribution model $B(10,0.5)$.

According to this,

• The probability of getting 4 heads is
• The probability of getting 2 or less heads is
• And the expected number of heads is

Example. In a population there are a 40% of smokers. The variable $X$ that measures the number of smokers in a random sample with replacement of 3 persons follows a binomial distribution model $X\sim B(3,\,0.4)$.

## Poisson distribution $P(\lambda)$

Usually the Poisson distribution correspond to a variable measured in a random experiment with the following features:

• The experiment consists of observing the number of events occurring in a fixed interval of time or space. For instance, number of births in a month, number of emails in one hour, number of red blood cells in a volume of blood, etc.
• The events occur independently.
• The experiment produces the same average rate of events $\lambda$ for every interval unit.

Under these conditions, the discrete random variable $X$ that measures the number of events in an interval unit follows a Poisson distribution model with parameter $\lambda$.

Definition - Poisson distribution $P(\lambda)$. A discrete random variable $X$ follows a Poisson distribution model with parameter $\lambda$, noted $X\sim P(\lambda)$, if its range is $\mbox{Ran}(X) = {0,1,\ldots,\infty}$ and its probability function is

Observe that $\lambda$ is the average rate of event for an interval unit, and it will change if the interval changes.

The mean and the variance are

Example. In a city there are an average of 4 births every day. The random variable $X$ that measures the number of births in a day in the city follows a Poisson distribution model $X\sim P(4)$.

According to this,

• The probability that there are 5 births in a day is
• The probability that there are less than 2 births in a day is
• The probability that there are more than 1 birth a day is

### Approximation of Binomial by Poisson distribution

The Poisson distribution can be obtained from the Binomial distribution when the number of trials repetition tends to infinite and the probability of Success tends to zero.

Law or rare events. The Binomial distribution $X\sim B(n,p)$ tends to the Poisson distribution $P(\lambda)$, with $\lambda=n\cdot p$, when $n$ tends to infinite and $p$ tends to zero, that is,

In practice, this approximation can be used for $n\geq 30$ and $p\leq 0.1$.

Example. A vaccine produce an adverse reaction in 4% of cases. If a sample of 50 persons are vaccinated, what is the probability of having more than 2 persons with an adverse reaction?

The variable that measures the number of persons with an adverse reaction in the sample follows a Binomial distribution model $X\sim B(50,0.04)$, but as $n=50>30$ and $p=0.04<0.1$, we can apply the law of rare events and use the Poisson distribution model $P(50\cdot 0.04)=P(2)$ to do the calculations.

1. To distinguish population statistics from sample statistics we use Greek letters