A random variable (also called random quantity, aleatory variable, or stochastic variable) is a mathematical formalization of a quantity or object which depends on random events. The term 'random variable' in its mathematical definition refers to neither randomness nor variability but instead is a mathematical function in which
- the domain is the set of possible outcomes in a sample space (e.g. the set which are the possible upper sides of a flipped coin heads or tails as the result from tossing a coin); and
- the range is a measurable space (e.g. corresponding to the domain above, the range might be the set if say heads mapped to −1 and mapped to 1). Typically, the range of a random variable is a subset of the real numbers.
Informally, randomness typically represents some fundamental element of chance, such as in the roll of a die; it may also represent uncertainty, such as measurement error. However, the interpretation of probability is philosophically complicated, and even in specific cases is not always straightforward. The purely mathematical analysis of random variables is independent of such interpretational difficulties, and can be based upon a rigorous axiomatic setup.