Mean and Variance

The notion of the mean of a set of numbers is easy to assume familiar to everyone, at least intuitively. This section nevertheless provides a brief review, gives the relevant definitions, and highlights some interesting aspects.

For $n$ samples of an observed quantity $x$, the sample mean is denoted by $\bar{x}$ and is given by

\begin{displaymath}
\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i
\end{displaymath} (2.1)

By definition, the sample mean is an empirical quantity.

If infinitely many values of $x$ could be sampled, $\bar{x}$ would converge to the theoretical, expected value. This is the Law of Large Numbers (Law of Large Numbers).

The expected value (expectation, mean) of a random variable $X$ is denoted by $\E[X]$ or $\mu$ and can be calculated for discrete random variables using

\begin{displaymath}
\E[X] = \mu_x = \sum_{-\infty}^{+\infty} x_i p_X(x_i)
\end{displaymath} (2.2)

and for continuous random variables using
\begin{displaymath}
\E[X] = \mu_x = \int_{-\infty}^{+\infty} x p_X(x) dx
\end{displaymath} (2.3)

given the probability distribution $p_X(x)$.

We now introduce the concept of the mean of a function of a random variable.

Definizione 5   Let $X$ be a random variable and $g(x)$ a measurable function. In the discrete case, the expected value of the random variable $Y=g(X)$ is defined as
\begin{displaymath}
\E[g(X)] =
\sum_i g(x_i) p_X(x_i),
\end{displaymath} (2.4)

while in the continuous case it is defined as
\begin{displaymath}
\E[g(X)] =
\int_{-\infty}^{+\infty} g(x) p_X(x)\,dx.
\end{displaymath} (2.5)

The means of some functions have particular significance. When $g(x)=x$, we speak of the first-order moment (first statistical moment); more generally, when $g(x)=x^{k}$, we speak of moments of order $k$. The expected value is therefore the first-order statistic, and another statistic of particular interest is the second-order moment:

\begin{displaymath}
\E[X^{2}] = \int_{-\infty}^{+\infty} x^{2} p_X(x) dx
\end{displaymath} (2.6)

This statistic is important because it allows us to estimate the variance of $X$.

The variance is defined as the expected value of the square of the random variable $X$ after subtracting its expected value; in other words, it is the second-order moment of the function $g(X)= X-\E[X]$:

\begin{displaymath}
\text{var}(X) = \sigma^{2}_X = \E[ (X - \E[X])^{2} ]
\end{displaymath} (2.7)

Since $\E[X]$ is a constant, expanding the square gives the equivalent and widely used form
\begin{displaymath}
\text{var}(X) = \sigma^{2}_X = \E[X^{2}] - \E[X]^{2}
\end{displaymath} (2.8)

The square root of the variance is known as the standard deviation (standard deviation) and has the advantage of having the same units as the observed quantity:

\begin{displaymath}
\sigma_X = \sqrt{ \text{var}(X) }
\end{displaymath} (2.9)

We now extend the concepts introduced so far to the multivariate case. This case can be viewed as an extension to multiple dimensions, with a different variable associated with each dimension.

The covariance matrix $\Sigma$ is the multidimensional (or multivariable) extension of the concept of variance. It is constructed as follows:

\begin{displaymath}
\Sigma_{ij} =\text{cov}(X_i,X_j)
\end{displaymath} (2.10)

where each matrix element contains the covariance between the different components of the random vector $X$. Covariance indicates how the different random variables that make up the vector $X$ are related to one another.

The covariance matrix can be denoted in several ways:

\begin{displaymath}
\Sigma = \E \left[ (X - \E[X])(X - \E[X])^{\top} \right] = \text{var}(X) = \text{cov}(X) = \text{cov}(X,X)
\end{displaymath} (2.11)

The notation for the cross-covariance matrix is, however, unique:

\begin{displaymath}
\text{cov}(X,Y) = \E \left[ (X - \E[X])(Y - \E[Y])^{\top} \right]
\end{displaymath} (2.12)

This generalizes the concept of the covariance matrix. The cross-covariance matrix $\boldsymbol\Sigma$ has, at position $(i,j)$, the covariance between the random variable $X_i$ and the variable $Y_j$:
\begin{displaymath}
\boldsymbol\Sigma = \begin{bmatrix}
\text{cov}(X_1,Y_1) & \...
...cov}(X_1,Y_m) & \cdots & \text{cov}(X_n,Y_m) \\
\end{bmatrix}\end{displaymath} (2.13)

The covariance matrix $\text{cov}(X,X)$ is therefore symmetric.

The covariance matrix describes how the different components are correlated with one another and is also called the scatter matrix (scatter matrix). When the covariance matrix is nonsingular, its inverse is called the precision matrix (or concentration matrix).

In the scalar case, the correlation coefficient between two random variables $X$ and $Y$ is defined as

\begin{displaymath}
r(X,Y) =
\frac{\text{cov}(X,Y)}
{\sqrt{\text{var}(X)\,\text{var}(Y)}}
=
\frac{\text{cov}(X,Y)}
{\sigma_X \sigma_Y}.
\end{displaymath} (2.14)

The correlation coefficient takes values in the interval $[-1,1]$. Values close to $1$ indicate strong positive correlation, values close to $-1$ indicate strong negative correlation, while values close to $0$ indicate no linear correlation2.1.

In the multivariate case, a correlation matrix is defined similarly by normalizing the cross-covariance matrix so that each element represents the correlation coefficient between a component of $X$ and a component of $Y$. Here too, all matrix elements belong to the interval $[-1,1]$.



Footnotes

... correlation2.1
A zero correlation coefficient implies no linear correlation but does not necessarily imply statistical independence.
Paolo medici
2026-10-19