View source: R/functions_ABC.R
weighted_stats | R Documentation |
Computes the weighted mean, median and quantiles of a distribution.
weighted_stats(x, w, prob = c(0.05, 0.25, 0.75, 0.95))
x |
numeric vector of size n with the observations. |
w |
numeric vector of size n with non-negative weights. Note that this
vector needs to have the same length as the |
prob |
numeric vector of probabilities with values in |
This function requires the MetricsWeighted::weighted_quantile()
function
and the weights to compute the weighted arithmetic mean and the weighted
quantiles. By default, this function computes the 5%, 25%, 50% (corresponding
to the median), 75% and 95% quantiles.
numeric vector with weighted mean, median and quantiles of size
2 + length(prob)
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.