weighted_mean_univariate: Calculate the weighted mean (univariate)

View source: R/RcppExports.R

weighted_mean_univariateR Documentation

Calculate the weighted mean (univariate)

Description

Calculation of weighted mean when the target is univariate

Usage

weighted_mean_univariate(x, weights)

Arguments

x

vector of values

weights

vector of weights

Value

the weighted mean of x

Examples

x <- c(0.4, 0.2, 0.5, 0.9, 1.4)
w <- c(3, 2, 5, 1, 2)
weighted_mean_univariate(x = x,
                         weights = w)
# returns the same using weighted.mean(x, w) function in R
weighted.mean(x, w)

weighted_mean_univariate(x = x,
                         weights = rep(1, 5))
#returns the same using standard mean(x) function in R
mean(x)

rchan26/hierarchicalFusion documentation built on Sept. 11, 2022, 10:30 p.m.