A random variable is a measurable map, and its distribution is the pushforward measure it induces. This viewpoint separates the random object from the particular probability space used to realize it.
Random variables as measurable maps
Measurability is what makes events of the form \(\{X\in B\}\) legitimate.
Definition. A random variable with values in a measurable space \((S,\mathcal S)\) is a measurable map \(X:(\Omega,\mathcal F)\to(S,\mathcal S)\). Its distribution, or law, is the probability measure \(P_X\) on \(S\) defined by \(P_X(B)=P(X\in B)\).
Proposition. If \(S=\mathbb R^d\) with its Borel sigma-field, then \(X\) is measurable if and only if every coordinate \(X_j\) is measurable. For a real \(X\), it is enough to check \[ \{X\le q\}\in\mathcal F\qquad(q\in\mathbb Q). \]
Proof. Coordinate projections are continuous, so measurability of \(X\) implies that of each \(X_j\). Conversely, inverse images of rectangles \(\prod_j(-\infty,q_j]\) are finite intersections of coordinate events; these rational rectangles generate \(\mathcal B(\mathbb R^d)\). The one-dimensional statement is the same argument with rational half-lines.
Distribution determines expectations
Every measurable calculation involving only \(X\) can be transferred to its law.
Theorem. If \(g:S\to\mathbb R\) is measurable and either nonnegative or \(g(X)\in L^1(P)\), then \[ \mathbb E[g(X)]=\int_S g(s)\,P_X(\mathrm{d}s). \]
Proof. For indicators \(g=1_B\), the identity is the definition of \(P_X\). By linearity it holds for nonnegative simple functions. Monotone convergence gives the nonnegative measurable case, and decomposing \(g=g^+-g^-\) gives the integrable case.
Corollary (law of the unconscious statistician). If a real \(X\) has density \(p\), then \[ \mathbb E[g(X)]=\int_{\mathbb R}g(x)p(x)\,\mathrm{d}x. \] If \(P(X=x_j)=p_j\), then \(\mathbb E[g(X)]=\sum_jg(x_j)p_j\). Both are instances of integration against \(P_X\), not separate definitions of expectation.
Functions of random variables
Proposition (mapping of laws). If \(T:S\to E\) is measurable, then \[ P_{T(X)}=P_X\circ T^{-1}. \] Therefore the law of \(T(X)\) depends only on the law of \(X\).
Proof. For \(B\in\mathcal E\), \[ P_{T(X)}(B) =P(T(X)\in B) =P(X\in T^{-1}(B)) =P_X(T^{-1}(B)). \]
Example (distributional transform). If \(X\) has continuous strictly increasing cdf \(F\), then \(U=F(X)\) is uniform on \((0,1)\), because \[ P(U\le u)=P(X\le F^{-1}(u))=u. \] Conversely, if \(U\sim\operatorname{Unif}(0,1)\) and \[ F^{-1}(u)=\inf\{x:F(x)\ge u\}, \] then \(F^{-1}(U)\) has cdf \(F\), even when \(F\) has jumps. This gives a canonical realization of every real probability law on one common probability space.
Equality in distribution
Two random variables may live on different probability spaces and still have the same probabilistic behavior.
Proposition. Random variables \(X\) and \(Y\) are equal in distribution, written \(X\stackrel{d}=Y\), if \(P_X=P_Y\). If \(S\) is a metric space with Borel \(\sigma\)-field, it is enough to check probabilities on a pi-system generating the Borel sets.
Proof. If probabilities agree on a generating pi-system, the pi-lambda theorem implies agreement on the generated \(\sigma\)-field. Therefore all bounded measurable expectations agree, and the variables have the same law.
Remark. The hierarchy \[ X=Y\text{ a.s.}\quad\Longrightarrow\quad X\stackrel d=Y \] cannot be reversed. Equality in law says only that all measurable tests have the same distributional averages; it says nothing about how \(X\) and \(Y\) are coupled on a common sample space. Two independent standard normals have the same law but satisfy \(P(X=Y)=0\).