This function calculates the \(n\)-th central moment, also known as the
\(n\)-th moment about the mean, of a ddf distribution.
Details
The \(n\)-th central moment of a random variable \(X\) is given by $$E[(X - E[X])^n],$$ where \(E\) is the expectation operator.
See also
Other moments:
moment(),
standardized_moment()
Examples
# The zeroth central moment is always 1
central_moment(bin(5, 0.4), 0)
#> [1] 1
# The first central moment is always 0
central_moment(hypergeometric(10, 7, 5), n = 1)
#> [1] 0
# The second central moment is the variance
central_moment(unif(10), 2)
#> [1] 8.25
# Result using the formula for the uniform distribution
(10^2 - 1) / 12
#> [1] 8.25
