I don't know about the statmod package and the gauss.quad function but generally the definition of Gauss-Hermite quadrature is with respect to the function that is multiplied by exp(-x^2) in the integrand. So your example would reduce to summing the weights.
On Sun, Nov 14, 2010 at 11:18 AM, Doran, Harold <hdo...@air.org> wrote: > Does anyone see why my code does not integrate to 1? > > library(statmod) > > mu <- 0 > s <- 1 > Q <- 5 > qq <- gauss.quad(Q, kind='hermite') > sum((1/(s*sqrt(2*pi))) * exp(-((qq$nodes-mu)^2/(2*s^2))) * qq$weights) > > ### This does what's it is supposed to > myNorm <- function(theta) (1/(s*sqrt(2*pi))) * exp(-((theta-mu)^2/(2*s^2))) > integrate(myNorm, -Inf, Inf) > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.