# Weighted sample covariance

I have read the Wikipedia article, and know that the unbiased weighted sample covariance matrix for the row vector $\mathbf{x}_i$ is $$\Sigma=\frac{1}{\sum_{i=1}^{N}w_i - 1}\sum_{i=1}^N w_i \left(\mathbf{x}_i - \mu^*\right)^T\left(\mathbf{x}_i - \mu^*\right),$$ in which $\mu^*$ is the weighted sample mean. I would like to figure out how to derive this, but I did not find the derivation from the reference.

The above equation applies when the weight is constant across variables. I also want to know how to calculate the weighted covariance of variables X and Y when they have different weights. For instance, the weight of X is w and that of Y is 1. Can someone help me? Thanks!

I have read another similar question, but I don't think the answer is correct. In that answer, $$\frac{\sum_{i=1}^k \sum_{j=1}^l (x_i-\bar{x}) (y_j-\bar{y}) a_i b_j} {\sum_{i=1}^k\sum_{j=1}^l a_i b_j}$$ (where $\bar{x}$ and $\bar{y}$ are respectively the weighted means of $x$ and $y$) is namely $$\frac{\sum_{i=1}^k (x_i-\bar{x})a_i\sum_{j=1}^l (y_j-\bar{y}) b_j} {\sum_{i=1}^ka_i\sum_{j=1}^l b_j},$$ in which $\sum_{i=1}^k (x_i-\bar{x})a_i=\sum_{j=1}^l (y_j-\bar{y}) b_j=0$, and thus the covariance calculated through this equation is 0. Also, they did not discuss how to derive the covariance matrix.

• I usually think of a weight $w_i$ as being assigned to a row of observations $(x_i, y_i)$ that share indices. Summing up mean-centered random vectors over separate, non-overlapping indices will always result in 0 as expectation would dictate. – AdamO Jan 2 '18 at 19:22