# Unbounded Numerical Integration, non-centered

**URL:** <https://discourse.julialang.org/t/unbounded-numerical-integration-non-centered/84947>\
**Category:** Numerics\
**Tags:** integral\
**Created:** [July 28, 2022, 10:34pm UTC](https://discourse.julialang.org/t/unbounded-numerical-integration-non-centered/84947 "2022-07-28T22:34:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ross\_Boylan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ross_boylan/32/9210_2.png) [@Ross\_Boylan](https://discourse.julialang.org/u/Ross_Boylan)\
**Post date:** [July 28, 2022, 10:34pm UTC](https://discourse.julialang.org/t/unbounded-numerical-integration-non-centered/84947/1 "2022-07-28T22:34:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [July 28, 2022, 11:05pm UTC](https://discourse.julialang.org/t/unbounded-numerical-integration-non-centered/84947/2 "2022-07-28T23:05:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ross\_Boylan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ross_boylan/32/9210_2.png) [@Ross\_Boylan](https://discourse.julialang.org/u/Ross_Boylan)\
**Post date:** [July 28, 2022, 11:40pm UTC](https://discourse.julialang.org/t/unbounded-numerical-integration-non-centered/84947/3 "2022-07-28T23:40:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ross\_Boylan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ross_boylan/32/9210_2.png) [@Ross\_Boylan](https://discourse.julialang.org/u/Ross_Boylan)\
**Post date:** [July 29, 2022, 1:43am UTC](https://discourse.julialang.org/t/unbounded-numerical-integration-non-centered/84947/4 "2022-07-29T01:43:31Z")

</div>

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.
