2
$\begingroup$

In cluster analysis I have frequently encountered a statement that the total sum of squares $\sum\limits_{i = 1}^n {{{({x_i} - \overline x )}^2}} $ being equal to within-cluster sum of squares $\sum\limits_{k = 1}^K {\sum\limits_{i = 1}^{{n_k}} {{z_{ik}}{{({x_i} - {{\overline x }_k})}^2}} } $ and between cluster sum of squares $\sum\limits_{k = 1}^K {\frac{{{n_k}}}{n}{{({{\overline x }_k} - \overline x )}^2}} $, where $n$ is the total number of elements, $K$ is the number of clusters, $n_k$ is the number of elements in the $k$th cluster, ${{{\overline x }_k}}$ is the mean of the $k$th cluster, $z_{ik}$ is an indicator function ${z_{ik}} = \left\{ {\begin{array}{*{20}{c}} 1&{{x_i} \in {\rm{cluster }}k}\\ 0&{{x_i} \notin {\rm{cluster }}k} \end{array}} \right.$. Anyone can provide a proof that the following equation indeed holds?

$\sum\limits_{i = 1}^n {{{({x_i} - \overline x )}^2}} = \sum\limits_{k = 1}^K {\sum\limits_{i = 1}^{{n_k}} {{z_{ik}}{{({x_i} - {{\overline x }_k})}^2}} } + \sum\limits_{k = 1}^K {{{{n_k}}}{{({{\overline x }_k} - \overline x )}^2}} $

Thank you!

$\endgroup$
4
  • 2
    $\begingroup$ The factor $n_k/n$ in the second term should probably be $n_k$. $\endgroup$
    – Lucas
    Apr 18 '15 at 8:13
  • $\begingroup$ Thanks Lucas. You are right. I have edited the question. $\endgroup$
    – Tony
    Apr 18 '15 at 15:52
  • 1
    $\begingroup$ To those who marked this question as duplicate. I don't think my question duplicates "Partitioning sum of squares". $\endgroup$
    – Tony
    Apr 18 '15 at 15:53
  • $\begingroup$ Can you explain why? It would help if you edited your question to state what you understand from the other Q & what you still need to know. Then you might get the answers you need, rather than just material that already didn't help you. $\endgroup$ Apr 18 '15 at 16:13
3
$\begingroup$

One way to see this would be to use the law of total variance, $$\text{Var}[X] = \text{E}[\text{Var}[X \mid K]] + \text{Var}[\text{E}[X \mid K]],$$ applied to the distributions \begin{align} p(x \mid k) &= \sum_i \frac{z_{ik}}{n_k} \delta(x - x_i), & p(k) &= \frac{n_k}{n}. \end{align}

The more direct proof is straightforward but lengthy, which is probably why it wasn't mentioned in your books. Using the binomial theorem and \begin{align} \sum_i z_{ik} &= n_k, & \sum_k z_{ik} &= 1, \end{align} it follows that \begin{align} \sum_i (x_i - \bar x)^2 &= \sum_i \sum_k z_{ik} (x_i - \bar x)^2 \\ &= \sum_i \sum_k z_{ik} (x_i - \bar x_k + \bar x_k - \bar x)^2 \\ &= \sum_k \sum_i z_{ik} \left( (x_i - \bar x_k)^2 + 2 (x_i - \bar x_k) (\bar x_k - \bar x) + (\bar x_k - \bar x)^2 \right) \\ &= \sum_k \sum_i z_{ik} (x_i - \bar x_k)^2 + 2 \sum_k \sum_i z_{ik} (x_i - \bar x_k) (\bar x_k - \bar x) + \sum_k \sum_i z_{ik} (\bar x_k - \bar x)^2 \\ &= \sum_k \sum_i z_{ik} (x_i - \bar x_k)^2 + 2 \sum_k (\bar x_k - \bar x) \left( \sum_i z_{ik} x_i - \sum_i z_{ik} \bar x_k \right) + \sum_k n_k (\bar x_k - \bar x)^2 \\ &= \sum_k \sum_i z_{ik} (x_i - \bar x_k)^2 + 2 \sum_k (\bar x_k - \bar x) \left( n_k \bar x_k - n_k \bar x_k \right) + \sum_k n_k (\bar x_k - \bar x)^2 \\ &= \sum_k \sum_i z_{ik} (x_i - \bar x_k)^2 + \sum_k n_k (\bar x_k - \bar x)^2. \end{align}

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.