# Understanding Gauss-Hermite Weights

I routinely use Gauss-Hermite as a tool for approximating complex integrals. While I am proficient in its applications, I am not proficient in its development. I am working to understand the weights for functions where $$g(x) \sim \mathcal{N}(0,1)$$ such as in

$$\int f(x) g(x)dx \approx \sum_{i=1}^kf(x_i)w_i$$

Papers such as this below:

https://dmbates.github.io/MixedModels.jl/latest/GaussHermite/

indicate that

$$g(x) = exp(-x_i^2)$$

where I am assuming $$x_i$$ are the corresponding nodes used in $$f(x_i)$$. I'm unable to replicate this in R as I show below. The first portion of code output shows the nodes and weights from the R function and then the second line is my attempt to apply the transformation to the nodes to create the weights.

library(statmod)
> gauss.quad.prob(10, dist = 'normal')
$nodes [1] -4.8594628 -3.5818235 -2.4843258 -1.4659891 -0.4849357 0.4849357 1.4659891 2.4843258 3.5818235 4.8594628$weights
[1] 4.310653e-06 7.580709e-04 1.911158e-02 1.354837e-01 3.446423e-01 3.446423e-01 1.354837e-01 1.911158e-02 7.580709e-04 4.310653e-06

> exp(-(gauss.quad.prob(10, dist = 'normal')\$nodes^2))
[1] 5.551438e-11 2.680628e-06 2.087319e-03 1.165862e-01 7.904423e-01 7.904423e-01 1.165862e-01 2.087319e-03 2.680628e-06 5.551438e-11


Clearly, I'm mistaken and fail to understand the development of the weights properly and am looking for some didactic support to further my understanding.

Thank you in advance.

## 1 Answer

Intuitively, quadrature approximation of an integral is replacing the function $$f(x)$$ under the integral by a close enough step-function $$\hat f (x)$$ (piecewise constant with a finite number of jumps).

Let $$-\infty=z_0 < z_1 < ... (pardon this abuse of notation) be the points of discontinuity of this step function, so that $$\forall x \in (z_j, z_{j+1}) : \hat f(x) = f(x_i)$$. Then the weights must be equal to the integrals of weighting function $$g(x)$$ over each of the intervals $$(z_j,z_{j+1})$$:

$$$$f(x) \approx \hat f(x) \Rightarrow \int_{-\infty}^{\infty} f(x)g(x) dx \approx \sum_{i=1}^n f(x_i) \int_{z_{i-1}}^{z_i} g(x) dx,$$$$

meaning that the weights must be a bit "fatter" than just $$g(x_i)$$, rather an integral of $$g(x)$$ over some neighborhood of $$x_i$$.

Mechanically, according to Wikipedia weights are NOT simply the weighting function evaluated in the nodes but are computed by the formula

$$$$w_{i}={\frac {2^{n-1}n!{\sqrt {\pi }}}{n^{2}[H_{n-1}(x_{i})]^{2}}}$$$$

where n is the number of nodes in desired approximation and $$H_n(x)$$ is the n-th Hermite polynomial, which is precisely supposed to evaluate the integral of $$g$$ in a neighborhood of a node.