Moment Generating Closure of a Probability Density Function
momentMaker <- function(n, f){ function(mu) integrate(function(x) (x-mu)^n * f(x, mean = mu), -Inf, Inf) } #3rd Moment of a Normal with mean 0 moment(3, dnorm)(0)