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.[1] The term 'random variable' in its mathematical definition refers to neither randomness nor variability[2] but instead is a mathematical function in which
\{H,T\}
H
T
\{-1,1\}
H
T
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.
In the formal mathematical language of measure theory, a random variable is defined as a measurable function from a probability measure space (called the sample space) to a measurable space. This allows consideration of the pushforward measure, which is called the distribution of the random variable; the distribution is thus a probability measure on the set of all possible values of the random variable. It is possible for two random variables to have identical distributions but to differ in significant ways; for instance, they may be independent.
It is common to consider the special cases of discrete random variables and absolutely continuous random variables, corresponding to whether a random variable is valued in a countable subset or in an interval of real numbers. There are other important possibilities, especially in the theory of stochastic processes, wherein it is natural to consider random sequences or random functions. Sometimes a random variable is taken to be automatically valued in the real numbers, with more general random quantities instead being called random elements.
According to George Mackey, Pafnuty Chebyshev was the first person "to think systematically in terms of random variables".[3]
A random variable
X
X\colon\Omega\toE
\Omega
E
\Omega
(\Omega,l{F},\operatorname{P})
X,Y,Z,T
The probability that
X
S\subseteqE
\operatorname{P}(X\inS)=\operatorname{P}(\{\omega\in\Omega\midX(\omega)\inS\})
In many cases,
X
E=R
When the image (or range) of
X
X
X
Any random variable can be described by its cumulative distribution function, which describes the probability that the random variable will be less than or equal to a certain value.
The term "random variable" in statistics is traditionally limited to the real-valued case (
E=R
E
E
E
E
This more general concept of a random element is particularly useful in disciplines such as graph theory, machine learning, natural language processing, and other fields in discrete mathematics and computer science, where one is often interested in modeling the random variation of non-numerical data structures. In some cases, it is nonetheless convenient to represent each element of
E
\Omega
(1 0 0 0 … )
(0 1 0 0 … )
(0 0 1 0 … )
N
N
N
N x N
F
F(x)
x
F(x)
1,2,\ldots,n
If a random variable
X\colon\Omega\toR
(\Omega,l{F},\operatorname{P})
X
\{\omega:X(\omega)=2\}
P(X=2)
pX(2)
Recording all these probabilities of outputs of a random variable
X
X
X
X
X
FX(x)=\operatorname{P}(X\lex)
and sometimes also using a probability density function,
fX
X
P
\Omega
pX
R
pX
X
X
fX=dpX/d\mu
pX
\mu
R
\Omega
\Omega
R
Consider an experiment where a person is chosen at random. An example of a random variable may be the person's height. Mathematically, the random variable is interpreted as a function which maps the person to their height. Associated with the random variable is a probability distribution that allows the computation of the probability that the height is in any subset of possible values, such as the probability that the height is between 180 and 190 cm, or the probability that the height is either less than 150 or more than 200 cm.
Another random variable may be the person's number of children; this is a discrete random variable with non-negative integer values. It allows the computation of probabilities for individual integer values – the probability mass function (PMF) – or for sets of values, including infinite sets. For example, the event of interest may be "an even number of children". For both finite and infinite event sets, their probabilities can be found by adding up the PMFs of the elements; that is, the probability of an even number of children is the infinite sum
\operatorname{PMF}(0)+\operatorname{PMF}(2)+\operatorname{PMF}(4)+ …
In examples such as these, the sample space is often suppressed, since it is mathematically hard to describe, and the possible values of the random variables are then treated as a sample space. But when two random variables are measured on the same sample space of outcomes, such as the height and number of children being computed on the same random persons, it is easier to track their relationship if it is acknowledged that both height and number of children come from the same random person, for example so that questions of whether such random variables are correlated or not can be posed.
If are countable sets of real numbers, and , then is a discrete distribution function. Here
\deltat(x)=0
x<t
\deltat(x)=1
x\get
\{an\}
The possible outcomes for one coin toss can be described by the sample space
\Omega=\{heads,tails\}
Y
fY
A random variable can also be used to describe the process of rolling dice and the possible outcomes. The most obvious representation for the two-dice case is to take the set of pairs of numbers n1 and n2 from (representing the numbers on the two dice) as the sample space. The total number rolled (the sum of the numbers in each pair) is then a random variable X given by the function that maps the pair to the sum:and (if the dice are fair) has a probability mass function fX given by:
Formally, a continuous random variable is a random variable whose cumulative distribution function is continuous everywhere.[10] There are no "gaps", which would correspond to numbers which have a finite probability of occurring. Instead, continuous random variables almost never take an exact prescribed value c (formally, ) but there is a positive probability that its value will lie in particular intervals which can be arbitrarily small. Continuous random variables usually admit probability density functions (PDF), which characterize their CDF and probability measures; such distributions are also called absolutely continuous; but some continuous distributions are singular, or mixes of an absolutely continuous part and a singular part.
An example of a continuous random variable would be one based on a spinner that can choose a horizontal direction. Then the values taken by the random variable are directions. We could represent these directions by North, West, East, South, Southeast, etc. However, it is commonly more convenient to map the sample space to a random variable which takes values which are real numbers. This can be done, for example, by mapping a direction to a bearing in degrees clockwise from North. The random variable then takes values which are real numbers from the interval [0, 360), with all parts of the range being "equally likely". In this case, '''''X''''' = the angle spun. Any real number has probability zero of being selected, but a positive probability can be assigned to any ''range'' of values. For example, the probability of choosing a number in [0, 180] is . Instead of speaking of a probability mass function, we say that the probability density of X is 1/360. The probability of a subset of [0, 360) can be calculated by multiplying the measure of the set by 1/360. In general, the probability of a set for a given continuous random variable can be calculated by integrating the density over the given set. More formally, given any [[Interval (mathematics)|interval]] , a random variable
XI\sim\operatorname{U}(I)=\operatorname{U}[a,b]
XI
[c,d]\sube[a,b]
where the last equality results from the unitarity axiom of probability. The probability density function of a CURV
X\sim\operatorname{U}[a,b]
[0,1]
\operatorname{D}
\operatorname{D}
A mixed random variable is a random variable whose cumulative distribution function is neither discrete nor everywhere-continuous. It can be realized as a mixture of a discrete random variable and a continuous random variable; in which case the will be the weighted average of the CDFs of the component variables.
An example of a random variable of mixed type would be based on an experiment where a coin is flipped and the spinner is spun only if the result of the coin toss is heads. If the result is tails, X = −1; otherwise X = the value of the spinner as in the preceding example. There is a probability of that this random variable will have the value −1. Other ranges of values would have half the probabilities of the last example.
Most generally, every probability distribution on the real line is a mixture of discrete part, singular part, and an absolutely continuous part; see . The discrete part is concentrated on a countable set, but this set may be dense (like the set of all rational numbers).
The most formal, axiomatic definition of a random variable involves measure theory. Continuous random variables are defined in terms of sets of numbers, along with functions that map such sets to probabilities. Because of various difficulties (e.g. the Banach–Tarski paradox) that arise if such sets are insufficiently constrained, it is necessary to introduce what is termed a sigma-algebra to constrain the possible sets over which probabilities can be defined. Normally, a particular such sigma-algebra is used, the Borel σ-algebra, which allows for probabilities to be defined over any sets that can be derived either directly from continuous intervals of numbers or by a finite or countably infinite number of unions and/or intersections of such intervals.[11]
The measure-theoretic definition is as follows.
Let
(\Omega,l{F},P)
(E,l{E})
(E,l{E})
X\colon\Omega\toE
B\inl{E}
l{F}
X-1(B)\inl{F}
X-1(B)=\{\omega:X(\omega)\inB\}
B\inl{E}
In more intuitive terms, a member of
\Omega
l{F}
P
E
l{E}
E
When
E
l{E}
l{B}(E)
E
(E,l{E})
E
E
R
In this case the observation space is the set of real numbers. Recall,
(\Omega,l{F},P)
X\colon\Omega → R
\{\omega:X(\omega)\ler\}\inl{F} \forallr\inR.
This definition is a special case of the above because the set
\{(-infty,r]:r\in\R\}
\{\omega:X(\omega)\ler\}=X-1((-infty,r])
The probability distribution of a random variable is often characterised by a small number of parameters, which also have a practical interpretation. For example, it is often enough to know what its "average value" is. This is captured by the mathematical concept of expected value of a random variable, denoted
\operatorname{E}[X]
\operatorname{E}[f(X)]
f(\operatorname{E}[X])
X
\operatorname{E}[X]
X
Mathematically, this is known as the (generalised) problem of moments: for a given class of random variables
X
\{fi\}
\operatorname{E}[fi(X)]
X
Moments can only be defined for real-valued functions of random variables (or complex-valued, etc.). If the random variable is itself real-valued, then moments of the variable itself can be taken, which are equivalent to moments of the identity function
f(X)=X
[X=green]
X
g\colonR → R
X
Y=g(X)
Y
FY(y)=\operatorname{P}(g(X)\ley).
If function
g
h=g-1
h
g
FY(y)=\operatorname{P}(g(X)\ley)= \begin{cases} \operatorname{P}(X\leh(y))=FX(h(y)),&ifh=g-1increasing,\\ \\ \operatorname{P}(X\geh(y))=1-FX(h(y)),&ifh=g-1decreasing. \end{cases}
With the same hypotheses of invertibility of
g
y
fY(y)=fXl(h(y)r)\left|
dh(y) | |
dy |
\right|.
If there is no invertibility of
g
y
xi
y=g(xi)
fY(y)=\sumifX(g
-1 | |
i |
(y))\left|
| |||||||||
dy |
\right|
where
xi=
-1 | |
g | |
i |
(y)
g
In the measure-theoretic, axiomatic approach to probability, if a random variable
X
\Omega
g\colonR → R
Y=g(X)
\Omega
g
(\Omega,P)
(R,dFX)
Y
Let
X
Y=X2
FY(y)=\operatorname{P}(X2\ley).
If
y<0
P(X2\leqy)=0
FY(y)=0 \hbox{if} y<0.
If
y\geq0
\operatorname{P}(X2\ley)=\operatorname{P}(|X|\le\sqrt{y}) =\operatorname{P}(-\sqrt{y}\leX\le\sqrt{y}),
so
FY(y)=FX(\sqrt{y})-FX(-\sqrt{y}) \hbox{if} y\ge0.
Suppose
X
FX(x)=P(X\leqx)=
1 | |
(1+e-x)\theta |
where
\theta>0
Y=log(1+e-X).
FY(y)=P(Y\leqy)=P(log(1+e-X)\leqy)=P(X\geq-log(ey-1)).
The last expression can be calculated in terms of the cumulative distribution of
X,
\begin{align} FY(y)&=1-
y | |
F | |
X(-log(e |
-1))\\[5pt] &=1-
1 | ||||||
|
\\[5pt] &=1-
1 | |
(1+ey-1)\theta |
\\[5pt] &=1-e-y. \end{align}
which is the cumulative distribution function (CDF) of an exponential distribution.
Suppose
X
fX(x)=
1 | |
\sqrt{2\pi |
Consider the random variable
Y=X2.
fY(y)=\sumifX(g
-1 | |
i |
(y))\left|
| |||||||||
dy |
\right|.
In this case the change is not monotonic, because every value of
Y
X
fY(y)=
-1 | |
2f | |
X(g |
(y))\left|
dg-1(y) | |
dy |
\right|.
The inverse transformation is
x=g-1(y)=\sqrt{y}
dg-1(y) | |
dy |
=
1 | |
2\sqrt{y |
Then,
fY(y)=2
1 | |
\sqrt{2\pi |
This is a chi-squared distribution with one degree of freedom.
Suppose
X
fX(x)=
1 | |
\sqrt{2\pi\sigma2 |
Consider the random variable
Y=X2.
fY(y)=\sumifX(g
-1 | |
i |
(y))\left|
| |||||||||
dy |
\right|.
In this case the change is not monotonic, because every value of
Y
X
fY(y)=fX(g
-1 | ||
(y))\left| | ||
1 |
| |||||||||
dy |
\right|+fX(g
-1 | |
2 |
(y))\left|
| |||||||||
dy |
\right|.
The inverse transformation is
x=
-1 | |
g | |
1,2 |
(y)=\pm\sqrt{y}
| |||||||||
dy |
=\pm
1 | |
2\sqrt{y |
Then,
fY(y)=
1 | |
\sqrt{2\pi\sigma2 |
This is a noncentral chi-squared distribution with one degree of freedom.
There are several different senses in which random variables can be considered to be equivalent. Two random variables can be equal, equal almost surely, or equal in distribution.
In increasing order of strength, the precise definition of these notions of equivalence is given below.
If the sample space is a subset of the real line, random variables X and Y are equal in distribution (denoted
X\stackrel{d}{=}Y
\operatorname{P}(X\lex)=\operatorname{P}(Y\lex) forallx.
To be equal in distribution, random variables need not be defined on the same probability space. Two random variables having equal moment generating functions have the same distribution. This provides, for example, a useful method of checking equality of certain functions of independent, identically distributed (IID) random variables. However, the moment generating function exists only for distributions that have a defined Laplace transform.
Two random variables X and Y are equal almost surely (denoted
X \stackrel{a.s.
\operatorname{P}(X ≠ Y)=0.
For all practical purposes in probability theory, this notion of equivalence is as strong as actual equality. It is associated to the following distance:
dinfty(X,Y)=\operatorname{ess}\sup\omega|X(\omega)-Y(\omega)|,
where "ess sup" represents the essential supremum in the sense of measure theory.
Finally, the two random variables X and Y are equal if they are equal as functions on their measurable space:
X(\omega)=Y(\omega) \hbox{forall}\omega.
This notion is typically the least useful in probability theory because in practice and in theory, the underlying measure space of the experiment is rarely explicitly characterized or even characterizable.
See main article: Convergence of random variables. A significant theme in mathematical statistics consists of obtaining convergence results for certain sequences of random variables; for instance the law of large numbers and the central limit theorem.
There are various senses in which a sequence
Xn
X