weighted_quantile computes the weighted lower sample quantile
Usage
weighted_quantile(x, w, probs, na.rm = FALSE)
Arguments
x
a numeric vector whose weighted sample quantiles are wanted
w
a numeric vector of weights
probs
a numeric vector of probabilities with values in [0,1]
na.rm
a logical value indicating whether NA values should be
stripped before the computation proceeds.
Value
Weighted sample quantiles
Details
Weighted lower quantiles are computed using an algorithm with \(O(n*log(n))\)
in worst-case time. There exist superior algorithms; see Cormen et al.
(2009, Problem 9.2).
References
Cormen,T.H., Leiserson, C.E., Rivest, R.L., and Stein, C. (2009):
Introduction to Algorithms, 3rd ed., Cambridge: MIT Press.