Random Variables as Measurable Functions
We usually picture a random variable as "a number that depends on chance". Rigorously, on a
probability space
(\Omega, \mathcal{F}, \mathbb{P}), a random
variable is a function
X : \Omega \to \mathbb{R}
that is measurable: for every Borel set
B \subseteq \mathbb{R}, the preimage
X^{-1}(B) = \{\,\omega \in \Omega : X(\omega) \in B\,\} \in \mathcal{F}.
Equivalently — and this is the version you will use constantly — it is enough that
\{X \le x\} \in \mathcal{F} for every
x \in \mathbb{R}.
Why measurability is the whole point
Measurability is not red tape — it is exactly what lets us assign a probability to
statements about X. The event "X is at
most x" is the set
\{X \le x\} = X^{-1}\big((-\infty, x]\big). If that set lives in
\mathcal{F}, then \mathbb{P} can speak
about it, and we may define
F_X(x) = \mathbb{P}(X \le x).
Without measurability the preimage might not be an event at all, and
\mathbb{P}(X \le x) would be meaningless. So measurability is the
bridge that carries probability from the abstract space
\Omega over to the real line where we actually compute.
A random variable as a map
Let X be the sum of two dice, so
X : \Omega \to \{2, 3, \dots, 12\}. Each outcome
\omega on the left is carried by an arrow to its value
X(\omega) on the number line. Choose a target value below: the
diagram highlights the preimage — the set of outcomes mapping there — which
is an event in \mathcal{F}. For example
X^{-1}(\{7\}) = \{(1,6),(2,5),(3,4),(4,3),(5,2),(6,1)\}.