robertness
3/29/2015 - 9:29 PM

Moment Generating Closure of a Probability Density Function

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)