7.3 Mean with Vector Notation

It is very useful to be able to compute a mean using vector-matrix notation. First, notice that the formula of the mean consists of computing a (weighted) sum. Second, recall that a sum of numbers can be expressed with an inner product by using the unit vector (or summation operator). If we denote \(\mathbf{1}_{n}\) a vector of ones of size \(n\), then the mean value of a vector \(\mathbf{x}\) can be obtained with an inner product:

\[ \bar{x} = \left(\frac{1}{n}\right) \mathbf{1}_{n}^\mathsf{T} \mathbf{x} \]

As you can tell, \(\bar{x}\) is calculated by multiplying the scalar \(1/n\) with the inner product \(\mathbf{1}_{n}^\mathsf{T} \mathbf{x}\), which is equivalent to:

\[ \bar{x} = \left(\frac{1}{n}\right) <\mathbf{1}_{n}, \mathbf{x}> = \left(\frac{1}{n}\right) <\mathbf{x}, \mathbf{1}_{n}> \]

This way of using an inner product can also be genelarized with the notation \(<\mathbf{a}, \mathbf{b}>_{M}\) which is simply an inner product in a vector space endowed with a metric matrix \(\mathbf{M}\)

\[ <\mathbf{a}, \mathbf{b}>_{M} = \mathbf{a}^\mathsf{T} \mathbf{M b} \]

If we use a metric matrix \(\mathbf{D} = diag(1/n)\) then we have that the mean is given by:

\[ \bar{x} = <\mathbf{x}, \mathbf{1}>_{D} = \mathbf{x}^\mathsf{T} \mathbf{D 1} \]