What is the Variance of a Vector? The Variance-Covariance Matrix
Consider a random vector:
$$\mathbf{X} = \begin{pmatrix} X_1 \\ X_2 \\ \vdots \\ X_n \end{pmatrix}$$
Then the “variance” of $\mathbf{X}$ is a matrix. We call it the variance-covariance matrix, and it is given by the following formula:
$$ \mathbb{V}\text{ar}( \mathbf{X}) = \begin{pmatrix} \mathbb{V}\text{ar}(X_1) & \mathbb{C}\text{ov}(X_1, X_2) & \cdots & \mathbb{C}\text{ov}(X_1, X_n) \\ \mathbb{C}\text{ov}(X_2, X_1) & \mathbb{V}\text{ar}(X_2) & \cdots & \mathbb{C}\text{ov}(X_2, X_n) \\ \vdots & \vdots & \ddots & \vdots \\ \mathbb{C}\text{ov}(X_n, X_1) & \mathbb{C}\text{ov}(X_n, X_2) & \cdots & \mathbb{V}\text{ar}(X_n) \end{pmatrix} $$
Note that the diagonal elements are variances; or covariances of one of the component random variables with itself. The remaining terms are covariances of two different components, labelled in a same way we label elements of a matrix in general.
Often we use a capital sigma for this matrix; $\mathbb{V}\text{ar}( \mathbf{X}) = \Sigma $.
Recall that for an ordinary random variable $X$, we have:
$$\mathbb{V}\text{ar}(aX) = a^2 \ \mathbb{V}\text{ar}(X)$$
Moving one $a$ to the end of the line, we could write this as:
$$ \mathbb{V}\text{ar}(aX) = a \ \mathbb{V}\text{ar}(X) \ a $$
Now, let $\mathbf{a} = \begin{pmatrix} a_1 \\ a_2 \\ \vdots \\ a_n \end{pmatrix}$ be a constant $n$-dimensional vector.
Then we can form the product:
$$\mathbf{a}^T \mathbf{X} = \begin{pmatrix} a_1 , a_2 , \dots , a_n \end{pmatrix} \begin{pmatrix} X_1 \\ X_2 \\ \vdots \\ X_n \end{pmatrix}$$
Expanding out, we see that this is an ordinary random variable; that is,
$$\mathbf{a}^T \mathbf{X} = a_1X_1 + a_2X_2 + \dots + a_n X_n$$
Then similarly to above, we have that
$$ \mathbb{V}\text{ar}( \mathbf{a}^T \mathbf{X})= \mathbf{a}^T \ \mathbb{V}\text{ar}( \mathbf{X}) \ \mathbf{a} $$
Moreover, if A is an $n \times n$ matrix whose entries are constants, then $A \mathbf{X}$ is another random vector with $n$ elements. We then have:
$$\mathbb{V}\text{ar}( A \mathbf{X})= A \ \mathbb{V}\text{ar}( \mathbf{X}) \ A^T $$
Notice that the “$T$” for “transpose” is now at the end of the formula.