vampire.amath.mean_center#

vampire.amath.mean_center(A)[source]#

Mean center the matrix A by subtracting its mean.

Parameters:
Andarray

Matrix with columns of features and rows of measurements.

Returns:
Bndarray

Mean-centered matrix.

Notes

Suppose we have a matrix \(\mathbf{A} \in \mathbb{R}^{m \times n}\) with \(n\) columns of features \(\mathbf{x}_1, \mathbf{x}_2, \dots, \mathbf{x}_n\) and \(m\) rows of measurements:

\[\begin{split}\mathbf{A} = \begin{bmatrix} | & | & & | \\ \mathbf{x}_1 & \mathbf{x}_2 & \cdots & \mathbf{x}_n \\ | & | & & | \\ \end{bmatrix}.\end{split}\]

The means of the features are \(\bar{x}_1, \bar{x}_2, \dots, \bar{x}_n\), respectively, and they are stored in the matrix

\[\begin{split}\mathbf{\bar{A}} = \begin{bmatrix} 1 \\ 1 \\ \vdots \\ 1 \end{bmatrix} \begin{bmatrix} \bar{x}_1 & \bar{x}_2 & \cdots & \bar{x}_n \end{bmatrix}.\end{split}\]

The mean-centered (mean-subtracted) data is then

\[\mathbf{B = A - \bar{A}}.\]