# Random variable

A random variable is the mathematical function of a random experiment.

A priori, the definition of a random variable is not very complex. It is a concept that can be defined in one sentence. However, it is more complex than appearances may indicate.

Now, in economipedia, as we always do, we will explain it in a frankly simple way. So, we will go in parts. What parts is the sentence made of?

Statistical variable## What is a random variable?

How can we check the sentence is basically made up of two concepts: mathematical function and random experiment. So this is where we should start. That is, by first understanding what a mathematical function is and, later, by defining what we mean by random experiment.

- Mathematical function: Simply put, it is an equation that assigns values to a variable (dependent variable) based on other variables (independent variables).
- Random experiment: It is a real-life phenomenon whose results are completely due to chance. That is, under the same initial conditions it gives different results.

In other words, it is an equation that describes or attempts to describe the results (with a number) of an event whose results are due to chance.

### What is the point of differentiating random variable from random experiment?

Let's think about the following case. We want to study whether a coin is perfect or is very close to being so. To do this, we are going to carry out a random experiment that consists of tossing the coin and recording the result.

The possible outcomes of the coin toss are heads and tails. We can denote them as c (heads) and + (tails). Now, we cannot operate by substituting heads and tails in the corresponding functions. What do we do to facilitate the mathematical procedure? Assign numbers:

Random variable X: 1 if heads and 0 if tails.

By assigning it a number, we can operate mathematically. Before with signs, we couldn't. That is the true goal of a random variable. Convert events with which we cannot operate mathematically into numbers. Another example could be predicting whether it rains or not. If it rains 1 and if it does not rain 0.

## Random variable and probability distribution

The relationship between random variable and probability distribution is very close. In fact, a probability distribution is actually the function of a random variable. That is, it is a function of a function. So we have two related but different concepts:

- Random variable: It is a function of a random experiment.
- Probability distribution: It is a function that establishes how the probability of a random variable is distributed.

## Random variable types

Within the random variables there are, fundamentally, two types. Its classification depends on the type of number that the mathematical function returns. A random variable can be of two types:

- Discrete Random Variable: A random variable is discrete if the numbers it gives rise to are whole numbers. The way to calculate the probabilities of a discrete random variable is through the probability function.
- Continuous Random Variable: A random variable is continuous in case the numbers to which it takes place are not whole numbers. That is, they have decimals. The probability of a given event corresponding to a continuous random variable is established by the density function.

## Random variable example

A random variable could well be the function of the results of rolling a die. It is important to distinguish between three concepts here.

- Given: It is not the random variable. The die is simply an object.
- Roll a die: It is not the random variable. The roll of a die is the random experiment.
- Results of rolling a die: Yes is the random variable. It is the function that collects the results of the roll of the dice. An example of a random variable could be: That a number greater than 2 comes up when rolling the dice.

X: That it comes out greater than 2 when rolling the dice

Probability distribution: 1/3 is not greater than 2 and 2/3 if it is greater than 2.

That is, the probability is distributed such that the probability that a number less than or equal to 2 is rolled is 1/3. Meanwhile, the probability that it is greater than 2 is 2/3

Therefore, our random variable will depend on the concrete result of the value of the die. The type of variable we are referring to is discrete. Why do we know? Because when we roll a die we can only get 6 possible outcomes. All of them are whole numbers. Specifically, between 1 and 6.