# How does unbiased cov.wt compute its value?

What is exactly the calculation used when calling cov.wt((faithful,c(1,2,3,4))$cov)? (Say the data faithful has 4 rows and 2 columns, coordinates x,y) I.e.: What is the formula it uses to compute the weighted covariance matrix$\Sigma\$?

The doumentation doesn't say, the internet shows more than one formula and the code is short but I don't understand it and want just a mathematical clear formula.

center <- colSums(wt * x)
x <- sqrt(wt) * sweep(x, 2, center, check.margin = FALSE)
cov <- crossprod(x)/(1-sum(wt^2))
cov

• I believe the solution can be found here. Mar 22 '19 at 14:56