Last chance! 50% off unlimited learning
Sale ends in
Compute the weighted mean and variance of a vector of numeric values. If no weights are supplied, defaults to computing the unweighted mean and the unweighted maximum-likelihood variance.
wt_dist(x, wt = rep(1, length(x)), unbiased = TRUE)wt_mean(x, wt = rep(1, length(x)))
wt_var(x, wt = rep(1, length(x)), unbiased = TRUE)
Vector of values to be analyzed.
Weights associated with the values in x.
Logical scalar determining whether variance should be unbiased (TRUE) or maximum-likelihood (FALSE).
A weighted mean and variance if weights are supplied or an unweighted mean and variance if weights are not supplied.
The weighted mean is computed as
The weighted variance is computed as
# NOT RUN {
wt_dist(x = c(.1, .3, .5), wt = c(100, 200, 300))
wt_mean(x = c(.1, .3, .5), wt = c(100, 200, 300))
wt_var(x = c(.1, .3, .5), wt = c(100, 200, 300))
# }
Run the code above in your browser using DataLab