Tutorials › Statistical Theory I - Probability and Distribution Theory › Means and Covariances Under Affine Maps

Multivariate Normal Distributions · Tutorial 706 of 994

Means and Covariances Under Affine Maps

Learn to calculate and verify the mean and covariance after applying a matrix transformation and a fixed shift to a random vector.

Advanced 10 min read

What You'll Learn

  • State the finite-moment conditions for affine mean and covariance formulas
  • Derive the transformed mean from linearity of expectation
  • Prove the covariance transformation formula from the centered-vector definition
  • Calculate transformed means and covariance matrices by explicit matrix multiplication
  • Identify how translation, mixing, and dimension reduction affect the results
  • Detect common errors involving the shift vector and matrix transpose

Why Affine Transformations Need Their Own Moment Calculation

A vector of measurements is often recoded, combined, or shifted before it is analyzed. For example, a matrix may convert measurements into weighted summaries, change units, or produce fewer outputs than inputs. To describe the resulting vector, we need to know how its location and variability change.

Let \(X\) be a random vector in \(\mathbb{R}^p\), with mean vector \(\mu\) and covariance matrix \(\Sigma\). Let \(A\) be a fixed \(m\times p\) matrix and \(b\) a fixed vector in \(\mathbb{R}^m\). The transformed vector is \(Y=AX+b\). The formulas for its mean and covariance follow from the definitions; they do not require \(X\) to be Gaussian. When \(X\) is Gaussian, the affine-image result gives the distributional context, and the calculations here identify its transformed mean and covariance.

Definition: For a random vector \(X\in\mathbb{R}^p\) with finite second moments, its mean is \(\mu=E[X]\), and its covariance matrix is $$ \Sigma=\operatorname{Cov}(X)=E\left[(X-\mu)(X-\mu)^{\mathsf T}\right]. $$ A deterministic affine transformation of \(X\) is \(Y=AX+b\), where \(A\in\mathbb{R}^{m\times p}\) and \(b\in\mathbb{R}^m\) are nonrandom.

Finite second moments mean \(E[\|X\|^2]<\infty\), where \(\|\cdot\|\) is the Euclidean norm. This condition ensures that the means and covariance entries used below exist and are finite. Because \(A\) and \(b\) are fixed and finite-dimensional, \(Y=AX+b\) also has finite second moments.

The Affine Moment Formulas

Theorem: Suppose \(X\in\mathbb{R}^p\) has finite second moments, \(E[X]=\mu\), and \(\operatorname{Cov}(X)=\Sigma\). For any fixed \(A\in\mathbb{R}^{m\times p}\) and \(b\in\mathbb{R}^m\), the vector \(Y=AX+b\) satisfies $$ E[Y]=A\mu+b,\qquad \operatorname{Cov}(Y)=A\Sigma A^{\mathsf T}. $$

Proof. Since \(A\) is deterministic, expectation distributes across its rows and across addition of the fixed vector \(b\). Therefore $$ E[Y]=E[AX+b]=AE[X]+b=A\mu+b. $$

To calculate covariance, first center \(Y\) using its mean: $$ Y-E[Y]=AX+b-(A\mu+b)=A(X-\mu). $$ The shift cancels. Applying the definition of covariance and pulling the fixed matrices outside the expectation gives $$ \begin{aligned} \operatorname{Cov}(Y) &=E\left[(Y-E[Y])(Y-E[Y])^{\mathsf T}\right]\\ &=E\left[A(X-\mu)(X-\mu)^{\mathsf T}A^{\mathsf T}\right]\\ &=A\,E\left[(X-\mu)(X-\mu)^{\mathsf T}\right]A^{\mathsf T}\\ &=A\Sigma A^{\mathsf T}. \end{aligned} $$ These expectations are well-defined entry by entry because \(X\) has finite second moments. This proves both formulas. \(\square\)

The dimensions provide a useful check: \(A\mu+b\) is an \(m\)-vector, while \(A\Sigma A^{\mathsf T}\) is an \(m\times m\) matrix. The transpose is essential: it makes the right-hand factor \(p\times m\), so the product is dimensionally valid. The result also shows that adding \(b\) changes the mean but does not change covariance.

Reading the Covariance Formula Entry by Entry

Write \(a_i^{\mathsf T}\) for row \(i\) of \(A\). The \(i\)th transformed coordinate is \(Y_i=a_i^{\mathsf T}X+b_i\). For output coordinates \(i\) and \(j\), the corresponding covariance entry is $$ \operatorname{Cov}(Y_i,Y_j)=a_i^{\mathsf T}\Sigma a_j. $$ If \(a_{ik}\) is entry \(k\) of row \(i\), expansion gives $$ \operatorname{Cov}(Y_i,Y_j)=\sum_{k=1}^{p}\sum_{\ell=1}^{p}a_{ik}\Sigma_{k\ell}a_{j\ell}. $$ Thus each output covariance depends both on the weights in the two rows and on the covariances among the input coordinates. Keeping only the input variances would generally omit important terms.

Worked Example: A Three-Coordinate Transformation

Suppose \(X\in\mathbb{R}^2\) has mean and covariance $$ \mu=\begin{pmatrix}1\\-2\end{pmatrix}, \qquad \Sigma=\begin{pmatrix}4&1\\1&9\end{pmatrix}. $$ Let $$ A=\begin{pmatrix}1&2\\-1&1\\2&0\end{pmatrix}, \qquad b=\begin{pmatrix}0\\3\\-1\end{pmatrix}. $$ Find the mean and covariance of \(Y=AX+b\).

First calculate the mean: $$ A\mu= \begin{pmatrix} 1(1)+2(-2)\\ -1(1)+1(-2)\\ 2(1)+0(-2) \end{pmatrix} = \begin{pmatrix}-3\\-3\\2\end{pmatrix}. $$ Adding \(b\) gives $$ E[Y]=A\mu+b= \begin{pmatrix}-3\\0\\1\end{pmatrix}. $$

For covariance, the shift \(b\) is not included. Multiply \(A\) by \(\Sigma\): $$ A\Sigma= \begin{pmatrix} 6&19\\ -3&8\\ 8&2 \end{pmatrix}. $$ Now multiply by \(A^{\mathsf T}\): $$ \operatorname{Cov}(Y)=A\Sigma A^{\mathsf T} = \begin{pmatrix} 44&13&12\\ 13&11&-6\\ 12&-6&16 \end{pmatrix}. $$ For instance, the first diagonal entry is \((6,19)(1,2)^{\mathsf T}=6+38=44\), and the covariance between the first and second outputs is \((6,19)(-1,1)^{\mathsf T}=-6+19=13\). The matrix is symmetric, as a covariance matrix must be. It is \(3\times3\) because \(Y\) has three coordinates, even though \(X\) has only two.

Two Further Consequences

The formula handles a transformation applied in stages just as consistently as one applied at once. This provides a useful independent check on calculations involving several fixed linear recodings.

Result: Let \(Z=AX+b\), and then let \(W=CZ+d\), where \(C\) and \(d\) are fixed and have compatible dimensions. Then \(W=(CA)X+(Cb+d)\), and its mean and covariance agree with those obtained by applying the affine moment formulas directly to this combined transformation.

Derivation. Substitution gives \(W=C(AX+b)+d=(CA)X+(Cb+d)\). Applying the formulas directly yields $$ E[W]=(CA)\mu+(Cb+d)=C(A\mu+b)+d. $$ Applying them in two stages instead gives \(E[Z]=A\mu+b\), so \(E[W]=CE[Z]+d=C(A\mu+b)+d\), the same mean. For covariance, the direct calculation is $$ \operatorname{Cov}(W)=(CA)\Sigma(CA)^{\mathsf T} =C A\Sigma A^{\mathsf T}C^{\mathsf T}. $$ The two-stage calculation gives \(\operatorname{Cov}(Z)=A\Sigma A^{\mathsf T}\), followed by \(\operatorname{Cov}(W)=C\operatorname{Cov}(Z)C^{\mathsf T}\), which is the same matrix. \(\square\)

A second useful implication is that the output covariance must be symmetric and positive semidefinite. Symmetry follows from \(\Sigma^{\mathsf T}=\Sigma\): $$ (A\Sigma A^{\mathsf T})^{\mathsf T}=A\Sigma A^{\mathsf T}. $$ For any \(u\in\mathbb{R}^m\), $$ u^{\mathsf T}A\Sigma A^{\mathsf T}u=(A^{\mathsf T}u)^{\mathsf T}\Sigma(A^{\mathsf T}u)\geq 0, $$ because a covariance matrix is positive semidefinite. This check works whether or not \(A\) is square or invertible.

Worked Example: A Shift and a Change of Scale

Suppose \(X\in\mathbb{R}^2\) has $$ \mu=\begin{pmatrix}1\\2\end{pmatrix}, \qquad \Sigma=\begin{pmatrix}2&-1\\-1&3\end{pmatrix}, $$ and define $$ Y=AX+b,\qquad A=\begin{pmatrix}2&0\\1&-1\end{pmatrix}, \qquad b=\begin{pmatrix}-1\\4\end{pmatrix}. $$

The transformed mean is $$ A\mu+b= \begin{pmatrix}2&0\\1&-1\end{pmatrix} \begin{pmatrix}1\\2\end{pmatrix} + \begin{pmatrix}-1\\4\end{pmatrix} = \begin{pmatrix}2\\-1\end{pmatrix} + \begin{pmatrix}-1\\4\end{pmatrix} = \begin{pmatrix}1\\3\end{pmatrix}. $$

For the covariance, $$ A\Sigma= \begin{pmatrix}4&-2\\3&-4\end{pmatrix}, \qquad A\Sigma A^{\mathsf T} = \begin{pmatrix}4&-2\\3&-4\end{pmatrix} \begin{pmatrix}2&1\\0&-1\end{pmatrix} = \begin{pmatrix}8&6\\6&7\end{pmatrix}. $$ The shift affects the mean but not this covariance calculation. The off-diagonal entry \(6\) is the covariance between the two transformed coordinates.

Worked Example: Combining Three Coordinates into Two

Let \(X\in\mathbb{R}^3\) have $$ \mu=\begin{pmatrix}0\\1\\2\end{pmatrix}, \qquad \Sigma=\begin{pmatrix}1&0&0\\0&4&0\\0&0&9\end{pmatrix}. $$ Take $$ A=\begin{pmatrix}1&1&0\\0&1&-1\end{pmatrix}, \qquad b=\begin{pmatrix}2\\-1\end{pmatrix}. $$

The mean is $$ A\mu+b= \begin{pmatrix}1\\-1\end{pmatrix} + \begin{pmatrix}2\\-1\end{pmatrix} = \begin{pmatrix}3\\-2\end{pmatrix}. $$ For covariance, $$ A\Sigma= \begin{pmatrix}1&4&0\\0&4&-9\end{pmatrix}, $$ and therefore $$ \operatorname{Cov}(Y)=A\Sigma A^{\mathsf T} = \begin{pmatrix}1&4&0\\0&4&-9\end{pmatrix} \begin{pmatrix}1&0\\1&1\\0&-1\end{pmatrix} = \begin{pmatrix}5&4\\4&13\end{pmatrix}. $$ Although the input has three coordinates, the output has two, so its covariance is \(2\times2\). In particular, the covariance \(4\) between the outputs comes from their shared use of the second input coordinate.

Common Mistakes and a Practical Check

A common incorrect calculation is to write \(\operatorname{Cov}(AX+b)=A\Sigma+b\), treating the shift as though it were a covariance contribution and omitting the right-hand matrix factor. The correction is to center the transformed vector first: \(AX+b-E[AX+b]=A(X-\mu)\). The shift disappears, and multiplying this centered vector by its transpose produces both \(A\) and \(A^{\mathsf T}\).

Another tempting shortcut is to transform only the diagonal entries of \(\Sigma\). That is generally wrong: when a row of \(A\) combines multiple coordinates, their covariances contribute to the variance of that output. Use the full product \(A\Sigma A^{\mathsf T}\), or verify its entries with the double-sum formula.

1
Check dimensions.
Confirm that \(A\) has one column for each input coordinate and that \(b\) has one entry for each output coordinate.
2
Transform the mean.
Calculate \(A\mu\), then add \(b\).
3
Transform the covariance.
Calculate \(A\Sigma A^{\mathsf T}\); do not include \(b\).
4
Check the result.
The covariance must have the output dimension, be symmetric, and be positive semidefinite.
Key takeaway: For a finite-second-moment random vector, a fixed affine map sends its mean to \(A\mu+b\) and its covariance to \(A\Sigma A^{\mathsf T}\). Translation changes location; the matrix \(A\) controls how variability is mixed and transformed.

Check Your Understanding

Use the affine moment formulas and show enough work to verify each calculation.

  1. If \(E[X]=\mu\) and \(\operatorname{Cov}(X)=\Sigma\), why does a fixed shift \(b\) appear in the mean formula but not in the covariance formula?
  2. For \(X\in\mathbb{R}^2\) with mean \((1,0)^{\mathsf T}\), covariance \(I_2\), and \(Y=2X+(3,-1)^{\mathsf T}\), calculate \(E[Y]\) and \(\operatorname{Cov}(Y)\).
  3. What dimensions must \(A\), \(\Sigma\), and \(A\Sigma A^{\mathsf T}\) have if \(X\in\mathbb{R}^p\) and \(AX+b\in\mathbb{R}^m\)?
  4. For the matrix \(A\) in the third worked example, explain which input coordinate contributes to the covariance between the two outputs.
  5. State two properties that a calculated affine-transformed covariance matrix must satisfy, and explain how each can help detect an arithmetic error.