# Deriving total (within class + between class) scatter matrix

I was fiddling with PCA and LDA methods and I am stuck at a point, I have a feeling that it is so simple that I can’t see it.

Within-class ($S_W$) and between-class ($S_B$) scatter matrices are defined as:

Total scatter matrix $S_T$ is given as:

where C is number of classes and N is number of samples $x$ are samples, $\mu_i$ is ith class mean, $\mu$ is overall mean.

While trying to derive $S_T$ I came up to a point where I had:

as a term. This needs to be zero, but why?

Indeed: