Computes weighted variance

Share:

Description

Computes weighted variance

Usage

1
2
3
weighted_var(x, w)

wvar(x, w)

Arguments

x

A numeric vector of length n.

w

A numeric vector of length n.

Details

weighted_variance implements weighted variance computation in the following form:

sum[w(i)'(x(i) - w.mean(x))^2/(1-n)]

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

Value

Numeric scalar with the weighted variance.

See Also

This function is used in diffmap.

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.