Random variable (source code)

= Random variable
{title2=$X:\Omega\to\mathbb R$}
{wiki}

= Real-valued random variable
{synonym}

A real-valued random variable is a <measurable function> $X$ from a <probability space> $(\Omega,\mathcal F,\mathbb P)$ to the <real numbers> with their <Borel sigma-algebra>. More general targets give <random elements>. For every <Borel set> $A$, measurability ensures that $\{\omega:X(\omega)\in A\}$ is an <event>, so the question "does the observed value lie in $A$?" has a defined <probability>.

The <function> $X$ is fixed; its input outcome is uncertain. This separates what we measure from how the uncertainty is modeled. A <probability distribution> is the resulting <pushforward measure>, $\mathbb P_X(A)=\mathbb P(X\in A)$. A <cumulative distribution function>, <probability mass function>, or <probability density function> describes that <measure> in an appropriate setting. The random variable and its <probability distribution> are different objects: the former also retains its relationship to other measurements on the same <sample space>.

For two independent uniform dice, let $U,V$ record their results and define $S=U+V$ and $M=\max(U,V)$. The 36 ordered pairs are equally likely, but the resulting <probability mass functions> differ:
$$
\mathbb P(S=s)=\frac{6-|s-7|}{36}\quad(2\leq s\leq12),\qquad
\mathbb P(M=m)=\frac{2m-1}{36}\quad(1\leq m\leq6).
$$
For the sum, count the diagonal of the outcome grid having total $s$. For the maximum, subtract the $(m-1)^2$ pairs with both results below $m$ from the $m^2$ pairs with both results at most $m$. These examples show how a deterministic <function> transforms a simple input <probability distribution> into a nonuniform output one.

\Image[/random-variable-dice-distributions.png]
{title=Different random variables on the same equally likely dice outcome space}

The corresponding <expected values> are $\mathbb E S=7$ and $\mathbb E M=161/36$. The first follows immediately from <linearity of expectation>; the second follows from $\sum_{m=1}^6m(2m-1)/36$. Neither number must be an attainable result. An <expected value> describes an average under the <probability measure>, not a prediction that the next observation will equal it.

The distinction between a random variable and its <probability distribution> matters for dependence. $U$ and $V$ have the same <discrete uniform distribution> and are <independent random variables>. $U$ and a second copy of $U$ also have that same marginal <probability distribution>, but they always agree. Their joint <probability distribution> is concentrated on the diagonal; the marginals alone cannot say which relationship holds. This is why a model for several measurements must specify their joint law or an appropriate <independence> assumption.

<Indicator random variables> turn <events> into numbers: $\mathbf1_A$ equals one on $A$ and zero elsewhere, and $\mathbb E\mathbf1_A=\mathbb P(A)$. This connects event counting with <expected value> and <variance>, and lets tools for <random variables> answer questions about <probabilities>. More complicated <functions> of observations can describe totals, waiting times, or estimation errors using the same framework.