Gauss-Hermite Quadrature (for approximating integrals w.r.t. a Gaussian density)
The basic idea in Gauss-Hermite Quadrature is that we can evaluate an integral of the form of the product of some function
where
In THIS repository, however, the weighting function used is a standard normal Gaussian density,
- Set the order of the Hermite polynomial
$n$ . This must be an integer >= 1. Higher$n$ will give higher accuracy, though it requires more evalauations of$f$ .
n = 10; % order for Gauss-Hermite polynomial
- Call compGaussHermiteQuadCoeffs to obtain the evaluation points
$r_i$ and the weights$w_i$
[rr,ww] = compGaussHermiteQuadCoeffs(n); % get points and weights
- Then, for any function of interest
$f$ , evaluate the integral of$f$ times a standard normal pdf over the reals via:
fIntegral = sum( f(rr) .* ww);
- To evaluate the integral of
$f$ times a Gaussian with mean$\mu$ and variance$\sigma^2$ , instead use:
fIntegral = sum( f(rr * sig + mu) .* ww));
- See the script testGaussHermiteQuadrature for an illustrated example, along with an evaluation of accuracy