GAUSSHERMITE Procedure |
@GAUSSHERMITE generates vectors of abscissas and weights for Gauss-Hermite numerical integration.
@GaussHermite( options ) (no parameters)
Options
N=(input) # of nodes
X=(output) VECTOR of abscissas
W=(output) VECTOR of weights
STANDARD/[NOSTANDARD]
With STANDARD, the X and W are adjusted for integration of \(f(x)\phi (x)\) rather than \(f(x)\exp \left( { - {x^2}} \right)\).
Description
Gauss-Hermite approximates an integral of the form:
(1) \(\int\limits_{ - \infty }^\infty {f(x)\exp ( - {x^2})dx}\)
for some function \(f\). An \(H\) term approximation is done with
(2) \(\int\limits_{ - \infty }^\infty {f(x)\exp ( - {x^2})dx} \approx \sum\limits_{h = 1}^H {{w_h}f({x_h})}\)
The weights \({{w_h}}\) and abscissas \({{x_h}}\) are different for different values of \(H\)---the abscissas are always symmetrical about zero, and the weights match for abscissas of opposite sign. In practice, the integral in (1) often isn't quite in the correct form, since, instead of \(\exp ( - {x^2})\), we may need to integrate against the density of a \(N(0,{\sigma ^2})\). However, a simple change of variables gives us:
(3) \(\frac{1}{{\sigma \sqrt {2\pi } }}\int\limits_{ - \infty }^\infty {f(x)\exp ( - \frac{1}{{2{\sigma ^2}}}{x^2})dx} \approx \sum\limits_{h = 1}^H {\frac{1}{{\sqrt \pi }}{w_h}f(\sigma \sqrt 2 {x_h})}\)
With the STANDARD option, it returns weights \({{\tilde w}_h} = {\pi ^{ - 1/2}}{w_h}\) and abscissas \({{\tilde x}_h} = \sqrt 2 {x_h}\), so to (approximately) integrate \(f\) times \(N(0,{\sigma ^2})\), you just need to compute:
(4) \(\sum\limits_{h = 1}^H {{{\tilde w}_h}f(\sigma {{\tilde x}_h})}\)
Gauss-Hermite integration can be used to approximate any integral over the real line, since
(5) \(\int\limits_{ - \infty }^\infty {g(x)dx} = \int\limits_{ - \infty }^\infty {\left[ {g(x)\exp ({x^2})} \right]\exp ( - {x^2})dx}\)
so you can apply Gauss-Hermite with \({f(x) = g(x)\exp ({x^2})}\). However, if \(g\) has thick tails (and, in particular, thicker tails than \({\exp ( - {x^2})}\)), the accuracy of the numerical integral will be quite low.
Example
This computes \(E\left( {\exp (X)} \right)\) where \(X\sim N\left( {0,\sigma ^2 } \right) \) using a 15 term Gauss-Hermite approximation. This can be computed exactly, so this does a comparison with that—they match almost exactly in this case.
If you have a closed-form expression for the \(f\) function, this is most easily computed using an SSTATS instruction over the number of terms.
compute sigma=0.5
compute h=15
@GaussHermite(N=h,X=X,W=W,standardize)
sstats 1 h exp(sigma*x(t))*w(t)>>integral
?"Approximate" integral "Exact" exp(.5*sigma^2)
Output (from example)
Approximate 1.13315 Exact 1.13315
Copyright © 2026 Thomas A. Doan