Skip to contents

This function calculates the weighted variance which is then used in the estimation step (E-step) of the EM algorithm

Usage

weighted_var(x, w, na.rm = FALSE)

Arguments

x

numeric vector

w

numeric vecotr of weights to be used in the caluclation of the weighted variance of x

na.rm

logical; remove NA values?

Value

numeric estimate of the weighted variance of x

Examples

a <- 1:10
b <- seq(0.1, 1, length.out = 10)

weighted_var(a, b)
#> [1] 6.875