A variable that can take random values. These values are the realizations of the outcomes of random experiments and can be expressed in the form of a probability function. Thus, every random variable has a probability or frequency distribution associated with it.
In tossing a fair coin, the random variable X may be used to denote the outcome of getting a Head. It is written as follows:
X = 1; if the coin turns up a Head
= 0; otherwise
The probabilities associated with each of the two outcomes are written as:
P(X = 1) = probability of getting a Head = number of outcomes favoring Heads/Total number of possible outcomes = ½ = 0.5. And similarly for P(X = 0).
Thus, the random variable X maps the outcomes of a random experiment (tossing a fair coin) to numbers (1 and 0, in this case).