0
$\begingroup$

I have the following equation which I cannot seem to figure out how to convert to matrix form (such that I can compute it efficiently in code).

$\Sigma_m = \sum_i r_{im}(x_i - \mu_m)(x_i-\mu_m)^T$

Where $x_i$ and $\mu_m$ are vectors.

I am pretty sure that $\sum_i(x_i - \mu_m)(x_i-\mu_m)^T = ZZ^T$ where $Z$ is the matrix whose $i^{th}$ row is $x_i - \mu_m$. But I'm not sure how to incorporate the $r_{im}$ term

$\endgroup$
2
  • $\begingroup$ Is $x_i$ a row or column vector? $\endgroup$
    – mvw
    Jan 15, 2016 at 5:03
  • $\begingroup$ its a column vector. so the result should be a matrix. $\endgroup$ Jan 15, 2016 at 5:59

2 Answers 2

1
$\begingroup$

Setting $d_{i,m} = x_i - \mu_m$ for the $N$ difference vectors then $$ \Sigma_m = \sum_{i=1}^N r_{im} d_{i,m} \, d_{i,m}^T $$ If $x_i$ is a row vector, then this is a weighted sum of the $N$ scalar products $d_{i,m}\, d_{i,m}^T = \lVert d_{i,m} \rVert^2$, with weights $r_{im}$. Thus a number.

If $x_i$ is a column vector, then $d_{i,m} \, d_{i,m}^T$ is the matrix $Z_{i,m} = (z_{jk})$ with $$ z_{jk} = (d_{i,m})_j \, (d_{i,m})_k $$ and $\Sigma_\mu$ is the weighted sum of those $N$ matrices $Z_{i,m}$, with weights $r_{im}$. This is a matrix.

$\endgroup$
4
  • $\begingroup$ Right. This is what I thought initially, but I had hoped there was a way to express the weighted sum of the $N$ matrices as some kind of concise matrix/vector product or something. I suppose this is not possible. $\endgroup$ Jan 15, 2016 at 5:58
  • $\begingroup$ Thanks for clarifying. Hm. Let me think. $\endgroup$
    – mvw
    Jan 15, 2016 at 6:02
  • $\begingroup$ It is not your suggested matrix. That one would contain vectors $d_{i,m}$ for different $i$. While the ones showing up, in the matrices which I named $Z_{i,m}$ use only the $d_{i,m}$ for one particular index $i$. $\endgroup$
    – mvw
    Jan 15, 2016 at 6:06
  • $\begingroup$ Out of the box, for optimization I see no more than symmetry $z_{jk} = z_{kj}$. $\endgroup$
    – mvw
    Jan 15, 2016 at 6:08
0
$\begingroup$

As far as, I can see, your term $r_{im}$ will be multiplied with each entry of the $i^{th}$ row for a particular value of {m}. You can also say that it is embedded with each of the term.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .