Dictionary of Applied Machine Learning

random variable

Updated on 2026-09-18

Typeset PDF version — the authoritative form of this entry

Python demo — a script that recomputes what this entry states and prints one line per check

A random variable (RV) is a measurable function that maps each outcome of a random experiment to an element of a measurable space. Important types of RVs include binary RVs, discrete random variables (discrete RVs), real-valued RVs, random vectors, and random matrices. The analysis of machine learning (ML) methods often relies on probabilistic models that represent data sources as RVs. The most widely used probabilistic model assumes that data points are independent and identically distributed (i.i.d.) RVs with a common probability distribution, which is unknown in general.

Definition

P-weatherThe weather on a given day in the Austrian city Krems is the outcome of a random experiment (Hyndman and Athanasopoulos, 2021). Each possible outcome $\omega$ is characterized by a maximum daytime temperature, the temperature at 13:00, and reading off this temperature assigns a real number $x(\omega)$ to the outcome. This assignment is an RV $x$. The temperatures recorded on consecutive days are realizations of this RV (see Fig. 1).

Figure 1 of the entry rv
Figure 1: Each day's maximum daytime temperature, read at 13:00, is a realization of the real-valued RV $x$; the stem plot shows one realization per day over 30 consecutive days. Data generated by pythondemos/rv.py
More generally, an RV maps the outcomes of a random experiment to elements of a measurable space (Billingsley, 1986; Gray, 2009). Mathematically, an RV is a measurable function $x: \samplespace \rightarrow \featurespace$ whose domain is the sample space $\samplespace$ of a probability space and whose co-domain is a measurable space $\featurespace$. Measurability refers to the $\sigma$-algebras of the two spaces: the preimage $x^{-1}(B)$ of every measurable set $B \subseteq \featurespace$ must belong to the $\sigma$-algebra of the probability space, so that the probability of $x$ taking a value in $B$ is defined. The value $x(\omega) \in \featurespace$ that $x$ assigns to an outcome $\omega \in \samplespace$ is the image of $\omega$ under $x$ (see Fig. 2).
Figure 2 of the entry rv
Figure 2: An RV $x$ sends each outcome $\omega$ of a random experiment to its image $x(\omega)$ in a measurable space $\featurespace$. The black arrow follows one outcome; the gray arrows show the remaining outcomes, two of which share the same image. An RV can therefore map a large sample space into a small measurable space
The sample space and the RVs on it are a modeling choice, not fixed by the data. The daily Krems temperatures admit two standard constructions (Fig. 3). In the first, each day $\sampleidx$ has its own probability space with sample space $\samplespace^{(\sampleidx)}$, and the temperature of that day is an RV $x^{(\sampleidx)} : \samplespace^{(\sampleidx)} \rightarrow \reals$; the recorded value is one realization $x^{(\sampleidx)}(\omega^{(\sampleidx)})$. In the second, one probability space with sample space $\samplespace$ carries the whole reality: a single outcome $\omega \in \samplespace$ fixes the temperatures of all days simultaneously, and each day is an RV $x^{(\sampleidx)} : \samplespace \rightarrow \reals$ on this common space. The independent and identically distributed (i.i.d.) assumption is a statement about the second construction: the $x^{(\sampleidx)}$ share one probability distribution and are independent. The common-space construction is the one used for learning from data, because a single probability distribution then governs an entire dataset.
Figure 3 of the entry rv
Figure 3: Two constructions for the daily Krems temperatures $t_{\sampleidx}$. (a) Each day $\sampleidx$ has its own probability space with sample space $\samplespace^{(\sampleidx)}$ and RV $x^{(\sampleidx)}$, with a separate outcome per day. (b) One probability space with sample space $\samplespace$ carries the whole reality, so a single outcome $\omega$ fixes every day's temperature $t_{\sampleidx} = x^{(\sampleidx)}(\omega)$; only this construction supports modeling the days as i.i.d. RVs
Different types of RVs include In machine learning (ML), RVs represent data sources, so that the behavior of learning methods can be analyzed. For example, the generation of a training set or validation set is represented by i.i.d. RVs sharing one underlying probability distribution; this is the common-space construction, in which a single probability distribution governs the whole dataset. This probability distribution is either postulated or estimated from actual datasets, for example via maximum likelihood. Ideally, an ML method should work well on datasets that arise as realizations of high probability. This is the generalization goal that empirical risk minimization (ERM) pursues, minimizing the average loss on the training set as a proxy for the expected loss of the learned hypothesis on a new data point drawn from the common probability distribution.

See also: function, random experiment, sample space, probability space, vector, Euclidean space, probability, measurable, realization, probabilistic model, random vector, random matrix, sub-Gaussian random variable.

References

  1. Hyndman and Athanasopoulos (2021). Forecasting: Principles and Practice. OTexts. otexts.com/fpp3/
  2. Billingsley (1986). Probability and Measure. Wiley.
  3. Gray (2009). Probability, Random Processes, and Ergodic Properties. Springer Science+Business Media. doi.org/10.1007/978-1-4419-1090-5

Cite this entry

@misc{dictml_rv,
  author = {Jung, Alexander},
  editor = {Olioumtsevits, Konstantina and Schnoor, Ekkehard},
  title = {random variable},
  howpublished = {Dictionary of Applied Machine Learning (course edition)},
  year = {2026},
  doi = {10.5281/zenodo.21569296},
  note = {ISBN 978-952-64-3013-3, CC BY 4.0, retrieved 2026-09-22},
  url = {https://dictionaryofml.org/terms/rv.html}
}