Dictionary of Applied Machine Learning: 114 machine-learning terms, each with a definition, a figure, citations and a Python demo · All terms · Demos · Start here

mean

Updated on 2026-10-29

Readiness 100/100

▶ Run the Python demo Open in Colab Typeset PDF LaTeX source Markdown Cite this entry

See also random variable probability distribution empirical risk minimization linear regression

The mean of a random vector ${\mathbf x}$ is its expectation, the Lebesgue integral of ${\mathbf x}$ with respect to its probability distribution. The term also refers to the sample mean, i.e., the average of the data points in a dataset. The two usages are consistent: the sample mean is the mean of the random vector obtained by drawing a data point uniformly from the dataset. Both usages share a further characterization: for a random vector with a finite second moment, the mean is the unique solution of a risk minimization problem under the squared error loss. For the random vector from a dataset, this optimization problem reduces to empirical risk minimization (ERM) in the simplest regression setting: predicting a numeric label without features, for which the learned hypothesis is the sample mean of the labels.

Figure produced by the Python demo of the entry mean
Figure written by the entry's Python demo mean.py, which recomputes what the entry states: the script block by block · open in Colab

Definition

A weather station records the daily maximum temperature for a year. Adding the $365$ numbers and dividing by $365$ returns a single value that summarizes the whole record. This is the mean of the recorded numbers, and the same word names the corresponding quantity for a probability distribution.

P-defThe mean of a random vector ${\mathbf x}$, which takes on values in a Euclidean space $\mathbb{R}^{d}$, is its expectation $\mathbb{E}\{{\mathbf x}\}$. It is the Lebesgue integral of ${\mathbf x}$ with respect to its probability distribution $\mathbb{P}$ (e.g., see Billingsley (1986) or Rudin (1987)), i.e., \[ \mathbb{E}\{{\mathbf x}\} = \int_{\mathbb{R}^{d}} {\mathbf x} \, \mathrm{d}\mathbb{P}({\mathbf x}) \text{.} \] Here, $\mathbb{P}$ is the probability distribution that ${\mathbf x}$ induces on $\mathbb{R}^{d}$, so the integral runs over the values ${\mathbf x}$ takes rather than over the underlying sample space. No probability density function (pdf) need exist for the mean to be defined; when one does, denoted by $p$, it is $\int_{\mathbb{R}^{d}} {\mathbf x} \, p({\mathbf x}) \, \mathrm{d}{\mathbf x}$.

P-argminThe average of the opening paragraph is the sample mean of a finite dataset of sample size $m$, $\mathcal{D} = \left\{ {\mathbf x}^{(1)}, \,\ldots, \,{\mathbf x}^{(m)} \in \mathbb{R}^{d}\right\}$. These two usages are consistent. A dataset defines a discrete random variable (discrete RV) $\widetilde{{\mathbf x}}^{(\mathcal{D})}={\mathbf x}^{(I)}$ on the sample space $\{1, \,\ldots, \,m\}$. Here, the index $I$ is chosen uniformly at random, i.e., $\mathbb{P}\left(I=r\right)=1/m$ for all $r=1,\ldots,m$. The mean of $\widetilde{{\mathbf x}}^{(\mathcal{D})}$ is precisely the sample mean \[ ({1}/{m}) \sum_{r=1}^{m} {\mathbf x}^{(r)} \text{.} \] The probability distribution of $\widetilde{{\mathbf x}}^{(\mathcal{D})}$, which places mass $1/m$ on each data point, is the empirical distribution of the dataset. Fig. 1 shows both readings for a real-valued random variable (RV) and a dataset of seven numbers, with the empirical distribution drawn as its cumulative distribution function (cdf).

Figure 1 of the entry mean
Figure 1: The two readings of mean. (a) A real-valued RV with the standard normal pdf has mean $\expect\{\feature\} = 0$, the Lebesgue integral of $\feature$ against that pdf. (b) The $\samplesize = 7$ data points average to the sample mean $0.1$. (c) The empirical distribution of the same data points, drawn as its cdf $\cdf{\dataset}{\feature}$: a staircase rising by $1/\samplesize$ at each data point, from $0$ to $1$. It is the probability distribution of the discrete RV $\widetilde{\featurevec}^{(\dataset)}$ above, and its mean is the sample mean of (b). The sample mean $0.1$ of (b) and (c) differs from the mean $0$ of the RV in (a) because $\samplesize$ is finite
The two readings are further connected by a shared characterization. Consider any random vector with a finite second moment, i.e., $\mathbb{E}\{ \left\lVert {\mathbf x} \right\rVert_{2}^{2} \} < \infty$. Its mean is the unique solution of the following risk minimization problem (Bertsekas and Tsitsiklis, 2008): \[ \mathbb{E}\{{\mathbf x}\} = \mathop{\mathrm{arg\,min}}_{{\mathbf c} \in \mathbb{R}^{d}} \mathbb{E} \big\{\left\lVert {\mathbf x} - {\mathbf c} \right\rVert_{2}^{2}\big \} \text{.} \] The objective function of this problem is a strictly convex function of the optimization variable ${\mathbf c} \in \mathbb{R}^{d}$.

P-robustFor the discrete RV that a dataset defines, the risk is the average squared error over the dataset, so this risk-minimization characterization applies directly to the simplest machine learning (ML) problem, predicting a numeric label without any features. Consider a training set $\mathcal{D}^{(\rm train)} = \big\{ y^{(1)}, \,\ldots, \,y^{(m)} \big\}$ that consists of labels $y^{(r)} \in \mathbb{R}$ only. A hypothesis is then a single number $h \in \mathbb{R}$ that serves as the prediction for every data point. Empirical risk minimization (ERM) with the squared error loss searches over candidate hypotheses $h' \in \mathbb{R}$ and learns \[ \widehat{h} = \mathop{\mathrm{arg\,min}}_{h' \in \mathbb{R}} \frac{1}{m} \sum_{r=1}^{m} \big(y^{(r)} - h'\big)^{2} = \frac{1}{m} \sum_{r=1}^{m} y^{(r)} \text{,} \] i.e., the learned hypothesis is the sample mean of the labels (see Fig. 2). This setting coincides with linear regression for data points that carry the constant scalar feature $x = 1$.

Figure 2 of the entry mean
Figure 2: A training set of $\samplesize = 5$ numeric labels $\truelabel^{(\sampleidx)}$ (filled circles) and the learned hypothesis $\learnthypothesis = 4$ (horizontal dashed line), which is the sample mean of the labels. The vertical gray segments are the errors $\truelabel^{(\sampleidx)} - \learnthypothesis$; the sample mean minimizes the average of their squares
Squaring the deviations also makes the mean sensitive to outliers. Moving one of $m$ data points by an amount $\delta$ shifts the sample mean by $\delta / m$, so a single corrupted data point can move the mean arbitrarily far. The trimmed mean that discards a fraction $\gamma$ at each end stays bounded however far at most $\gamma m$ data points are moved, and the median stays bounded however far up to half of the $m$ data points are moved. Both are therefore preferred when features or labels may be unreliable (Huber, 1992; pythondemos/mean.py).

Synonyms: expectation, expected value.

See also: random variable, random vector, expectation, sample mean, probability distribution, Lebesgue integral, empirical risk minimization, squared error loss, linear regression, median, trimmed mean.

References

  1. Billingsley (1986). Probability and Measure. Wiley.
  2. Rudin (1987). Real and Complex Analysis. McGraw-Hill.
  3. Bertsekas and Tsitsiklis (2008). Introduction to Probability. Athena Scientific.
  4. Huber (1992). Robust estimation of a location parameter. Breakthroughs in Statistics: Methodology and Distribution.

Cite this entry

@misc{dictml_mean,
  author = {Jung, Alexander},
  editor = {Olioumtsevits, Konstantina and Schnoor, Ekkehard},
  title = {mean},
  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-11-04},
  url = {https://dictionaryofml.org/terms/mean.html}
}