How to add new rows into a matrix $X$ without change its center?

38 Views Asked by At

Assume that you have a matrix $X \in \Re^{m \times n}$ and you have centered it column wise.

$$\mu_j = \frac{1}{m}\sum_{i=1}^{m} X_{i,j}$$ $$X = X - \mu_j$$

MATLAB code:

>> X = rand(10, 3);
>> mu = mean(X);
>> X = X - mu;

Now you want to add new rows into $X$ and still not change its centered position.

Question:

How can that be achieved?

1

There are 1 best solutions below

1
On BEST ANSWER

After shifting the matrix ($X' = X - \mu_j$), the mean value of each column becomes zero:

$$\mu_j' = \frac{1}{m}\sum\limits_{i=1}^{m} X'_{ij} = \frac{1}{m}\sum\limits_{i=1}^{m} X_{ij} - \frac{1}{m}\sum\limits_{i=1}^{m} \mu_j = \mu_j - \mu_j = 0$$

Therefore $\boxed{\sum\limits_{i=1}^{m} X'_{ij}=0}$

If we add $k$ new rows (stored in a matrix $Y \in \mathbb{R}^{k \times n}$) to the matrix $X'$, the new mean values are given by:

$$\mu_j'' = \frac{1}{m+k}\left[\sum\limits_{i=1}^{m}X'_{ij} + \sum\limits_{i=1}^{k}Y_{ij} \right] = \frac{1}{m+k}\,\sum\limits_{i=1}^{k}Y_{ij}$$

If you want to keep the mean value at zero, then, the sum of the new rows must be equal to zero:

$$\boxed{\mu_j'' = \mu_j' = 0 \Leftrightarrow \sum\limits_{i=1}^{k}Y_{ij}=0}$$