In probability and statistics, a

**random variable**,

**random quantity**,

**aleatory variable**, or

**stochastic variable** is a variable quantity whose possible values depend, in random manner, on a set of random outcomes events. It is common that the outcome depends on some physical variables that are not well understood. For example, when you toss a coin (or a die), it falls on its edge, and the final outcome (H,T) or {1-6} depends on the uncertain physics. What is not uncertain are the possible outcomes. Of course the coin could get caught in a crack in the floor, but that is not a consideration. Essential to the definition of a random variable, is the outcome space, typically defined in mathematics, in terms of set theory or a set. In the case of the coin, the set is binary. The member of the set are each labelled by a probability ($p_k$) where $k$ labels the possible outcome values. Thus for the coin example, there are {p,q} such that p+q=1. The only outcomes allowed are those from the set, thus one of these outcomes must have some measurable (non-zero) probability.

A random variable is defined as a function that maps probability to a physical outcome (labels), typically real numbers. In this sense, it is a procedure for assigning a probability to a physical outcome, and, contrary to its name, this procedure itself is neither random nor variable. What is random is the unstable physics that describes how the coin lands, and finally settles to the possible outcomes, with certainty 1.

The function which characterizes a random variable must also be measurable, which rules out certain pathological cases such as those in which the random variable's quantity is infinitely sensitive to any small change in the outcome.

A random variable's possible values might represent the possible outcomes of a yet-to-be-performed experiment, or the possible outcomes of a past experiment whose already-existing value is uncertain (for example, due to imprecise measurements or quantum uncertainty). They may also conceptually represent either the results of an "objectively" random process (such as rolling a die) or the "subjective" randomness that results from incomplete knowledge of a quantity. The meaning of the probabilities assigned to the potential values of a random variable is not part of probability theory itself but is instead related to philosophical arguments over the interpretation of probability. The mathematics works the same regardless of the particular interpretation in use.

A random variable has a

probability distribution, which specifies the probability that its value falls in any given interval. Random variables can be discrete, that is, taking any of a specified finite or countable list of values, endowed with a probability mass function characteristic of the random variable's probability distribution; or continuous, taking any numerical value in an interval or collection of intervals, via a probability density function that is characteristic of the random variable's probability distribution; or a mixture of both types. Two random variables with the same probability distribution can still differ in terms of their associations with, or independence from, other random variables. The realizations of a random variable, that is, the results of randomly choosing values according to the variable's probability distribution function, are called random variates.

The formal mathematical treatment of random variables is a topic in probability theory. In that context, a random variable is understood as a function defined on a sample space whose outputs are numerical values.