weighted_var function

Computes weighted variance

Computes weighted variance

weighted_var(x, w) wvar(x, w)

Arguments

  • x: A numeric vector of length nn.
  • w: A numeric vector of length nn.

Returns

Numeric scalar with the weighted variance.

Details

weighted_variance implements weighted variance computation in the following form:

%\frac{\sum_i w_i'(x_i - \bar x)^2}{(1-n)}%sum[w(i)'(x(i) - w.mean(x))^2/(1-n)]

where w(i)=w(i)/sum(w)w(i)' = w(i)/sum(w), and w.mean(x)=sum[w(i)x(i)]w.mean(x)=sum[w(i)'*x(i)].

See Also

This function is used in diffmap.