Unbounded Numerical Integration, non-centered

I’m interested in integrating f(x)\phi(x) over the entire real line, where \phi(x) is the Gaussian/Normal density function. Ordinarily the Gauss-Hermite method in FastGaussQuadrature would be good for this (with suitable change of variable adjustment). However, the mode of f(x)\phi(x) is sometimes far from 0, e.g., 4. So I think I need something adaptive. Any recommendations? Both the “finding the center and scale of the integrand” and “finding the number of points to use” senses of “adaptive” are of interest.

The adaptive methods I’ve found mostly work only on finite intervals, although QuadGK.quadgk does say the endpoints can be infinite. There also seem to be more choices among the Cubature related tools, but I don’t currently want to go multi-dimensional (perhaps later).

I’m also a bit tempted to just take the Gauss-Hermite node locations and shift them to match the center of the integrand, but my understanding is that those points come from roots of equations, and so shifting them seems liable to break a lot of the underlying assumptions that motivate using them in the first place. On the other hand, the theoretical result that the GH quadrature can give exact fit to integrals of finite order polynomials is already irrelevant: my f(x) generally includes an exponential term.

I would get estimates of the mode and scale of f(x)\phi(x) numerically.

Can’t you just shift x to x+4?

Shift how or where? If you mean evaluate f(x+4)\phi(x+4) that would be a normal distribution with a mean of -4, but the normal distribution I’m integrating against is a standard normal, mean 0. The mean of the integrand is so far from that because f(x) is much larger when x>>0.

On reflection, I think my idea of shifting the node locations has a similar failing. If I move to center the nodes on 4 I would effectively be integrating f(x)\phi(x-4), i.e., treating the normal distribution as if its mean were +4. Which it isn’t.