What is a random variable?

A random variable is a function that maps outcomes of an experiment, or process that produces outcomes with some degree of uncertainty, to quantifiable values. It basically translates the raw outcomes, such as Heads or Tails in the context of flipping a coin, into a numerical measure, such as 0 and 1, respectively.

It is common notation in statistics to refer to a stochastic process that generates data as a random variable such as X, where the capital X refers to the random variable itself and lowercase x refers to an instance of the random variable. A random variable can either be discrete, if the sample space consists of a finite number of countable elements (such as rolling a dice or flipping a coin), or continuous, if the sample space consists of an infinite number of events (such as annual rainfall received in a city).