In any experiment of chance, the outcomes occur randomly. For example, rolling a single die is an experiment: Any of the six possible outcomes can occur. Some experiments result in outcomes that are quantitative (such as dollars, weight, or number of children), and others result in qualitative outcomes (such as color or religious preferences). Therefore, random variables in statistics are variables whose value depends on the output of a random experiment.

A random variable is a mathematical abstraction that allows one to assign numerical values to the random variable associated with a probability to indicate the chance of a particular outcome.

### Random Experiment

In the random experiment, a numerical value say 0, 1, 2, is assigned to each sample point. Such a numerical quantity whose value is determined by the outcomes of an experiment of chances is known as a random variable (or stochastic variable). Therefore, a random experiment is a process that has a well-defined set of possible outcomes, however, the outcomes for any given trial of the random experiment cannot be predicted in advance. Examples of random experiments are: rolling a die, flipping a coin, and measuring the height of students walking into a class.

### Classification of Random Variables in Statistics

A random variable can be classified into a **discrete random variable** and a **continuous random variable**.

#### Discrete Random Variable

A discrete random variable can assume only a certain number of separated values. The discrete random variables can take only finite or countably infinite numbers of distinct values. For example, the Bank counts the number of credit cards carried by a group of customers. The other examples of discrete random variables are: (i) The number of successes in a 5-coin flip experiment, (ii) the number of customers arriving in a store during a specific hour, (iii) the number of students in a class, and (iv) the number of phone calls in a certain day.

#### Continuous Random Variable

The continuous random variable can assume any value within a specific interval. For example, the width of the room, the height of a person, the pressure in an automobile tire, or the CGPA obtained, etc. The continuous random variable assumes an infinitely large number of values, within certain limitations. For example, the tire pressure measured in pounds per square inch (psi) in most passenger cars might be 32.78psi, 31.32psi, 33.07psi, and so on (any value between 28 and 35). The random variable is the tire pressure, which is continuous in this case.

Definition: A random variable is a real-valued function that takes a defined value for every point in the sample space.

In most of the practical problems, *discrete random variables* represent count or enumeration data such as the number of books on a shelf, the number of cars crossing a bridge on a certain day or time, or the number of defective items in a production (or a lot). On the other hand, *continuous random variables* usually represent measurement data such as height, weight, distance, or temperature.

Note: A random variable represents the particular outcome of an experiment, while a probability distribution reports all the possible outcomes as well as the corresponding probability.

### Importance of Random Variables

The importance of random variables cannot be ignored, because random variables are fundamental building blocks in the field of probability and statistics. The random variables allow us to:

**Quantify Uncertainty: **Since numerical values are assigned to outcomes from a random experiment, one can use mathematical tools such as probability distributions to compute and analyze the likelihood of different events occurring.
**Statistical Analysis:** Random variables are essential for performing various types of statistical analyses such as computing expected values, and variance, conducting hypothesis testing, and computing relationships between variables, etc.
**Modeling Real-World Phenomena:** One can use random variables to model real-world phenomena with inherent randomness, allowing for predictions and simulations.

Note that each possible outcome of a random experiment is called a sample point. The collection of all possible sample points is called sample space, represented by $S$.

Read about Pseudo Random Numbers

MCQs C++ Language