I am using the Gauss-Laguerre quadrature to approximate the following integral
I wrote the function in R
int.gl<-function(x)
{
x^(-0.2)/(x+100)*exp(-100/x)
}
First, I used integrate()
function to get the "true" value, which I double check with Wolfram Alpha
integrate(int.gl, lower = 0, upper = Inf)$value
[1] 1.627777
Then, I used glaguerre.quadrature()
function
rule<-glaguerre.quadrature.rules(64, alpha = 0, normalized = F)[[64]]
glaguerre.quadrature(int.gl, lower = 0, upper = Inf, rule = rule, weighted = F)
[1] 0.03610346
Clearly, the result is far away from the true value. At that time, I thought I had to transform this function to include a e^(-x) term. So, let X = 1/Y. I obtained a different formula but the same integral
In the same manner, I used the following R code
int.gl2<-function(x)
{
x^(-0.8)/(1+100*x)*exp(-100*x)
}
integrate(int.gl2, lower = 0, upper = Inf)$value
[1] 1.627777
glaguerre.quadrature(int.gl2, lower = 0, upper = Inf, rule = rule, weighted = F)
[1] 0.03937068
Well, two different values. Does the Gauss-Laguerre quadrature have trouble in finding this integral? Is there any other Gauss-type quadrature can help find this integral?
Note: I have to use Gauss-type quadrature since I am trying to find MLEs of some parameters for a customized distribution. For simplicity, I just fixed these parameters(these constants in the integral). However, integrate()
function seems to be less "robust" than glaguerre.quadrature()
function. (integrate()
returns divergent error when optimizing the log-likelihood).
EDIT 1
According to Hans. W's comment, I check the use of glaguerre.quadrature
with the following example. Suppose we wanna find the following integral
int.gl3<-function(x)
{
((x+100)/(x+200))^0.2*exp(-5*x)
}
glaguerre.quadrature(int.gl3, lower = 0, upper = Inf, rule = rule, weighted = F)
[1] 0.1741448
integrate(int.gl3, lower = 0, upper = Inf)$value
[1] 0.1741448
It seems like the use of glaguerre.quadrature
is correct.
Let's check the transformation now. I transform this integral, by letting 100Y=X, such that it includes exp(-x).
int.gl4<-function(x)
{
0.01^0.2*x^(-0.8)/(1+x)*exp(-x)
}
integrate(int.gl4, lower = 0, upper = Inf)$value
[1] 1.627777
glaguerre.quadrature(int.gl4, lower = 0, upper = Inf, rule = rule, weighted = F)
[1] 0.9621667
The result is more close to the true value but not exactly equal.
EDIT 2
Here is my complete example