Computes a weighted mean of a vector, matrix, or a three dimensional array.
weighted_mean(x, w, na.rm)
A weighted mean.
A numeric vector, matrix, three dimensional array, or an mcmc
object from
the coda
package. For matrix, the mean is computed for each column, and
for array the sweep is done over the third dimension.
A numeric vector of non-negative weights. Will be automatically normalised to sum to one.
If TRUE
, NA
values in x
(and corresponding weights in w
) are
omitted from the computation. Default is FALSE
. Only used in vector methods.