center: Calculate centralized moments (default) or noncentralized moments, i.e. E((X - E(X))^k) or E(X^k).
Returns
A vector of length n where the kth entry is the kth weighted moment of x with weights w. If center is TRUE the moments are centralized, i.e. E((X - E(X))^k). The first moment is never centralized. The moments are scaled with 1 / sum(w), so they are not de-biased.
e.g. the second central weighted moment weighted_moment(x, w)[2L]
is equal to var(rep(x, w)) * (sum(w) - 1) / sum(w)