You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have just tried to integrate a Laplace distribution as
using QuadGK, Distributions
pc = Laplace(0, 1)
quadgk(x -> pdf(pc, x), -1e8, 1e8, rtol=1e-8)
(0.0, 0.0)
I obtain zero, which is obviously wrong as it should be one. The manual says that I should add an explicit point, when the point is non-smooth, which I do
The problem is that if you integrate from 1e-8 to 1e8 then the initial points are too spread out and it only samples your function PDF where it is close to zero. This kind of thing is an intrinsic limitation of any numerical quadrature scheme.
Simplest solution: if you want to integrate over the whole real line, integrate over the whole real line.
quadgk knows how to do something reasonable here (via a coordinate transformation).
Alternatives include increasing the integration order (the order parameter) to increase the number of sample points, breaking the integral into more subintervals to increase the number of initial sample points, or doing a coordinate transform on your interval to emphasize the origin (this is what the -Inf..Inf algorithm does internally).
Hi, I have just tried to integrate a Laplace distribution as
I obtain zero, which is obviously wrong as it should be one. The manual says that I should add an explicit point, when the point is non-smooth, which I do
But it does not help either. I think that the method just omit to sample around the zero sufficiently.
The text was updated successfully, but these errors were encountered: