Re: [R] Integrate to 1? (gauss.quad)

2010-11-16 Thread Enrico Schumann
: Montag, 15. November 2010 18:11 An: Douglas Bates Cc: r-help@r-project.org Betreff: Re: [R] Integrate to 1? (gauss.quad) Thank you, Doug. I am still missing something here. Should this simply be sum(f(x_i) * w_i) where x_i is node i and w_i is the weight at node i? So, my function f(x) = (1

Re: [R] Integrate to 1? (gauss.quad)

2010-11-15 Thread Doran, Harold
Subject: Re: [R] Integrate to 1? (gauss.quad) 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

[R] Integrate to 1? (gauss.quad)

2010-11-14 Thread Doran, Harold
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))) *

Re: [R] Integrate to 1? (gauss.quad)

2010-11-14 Thread Douglas Bates
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,