[R] Bug in myintegrate in Elliptic package
Luis Felipe Parra
felipe.parra at quantil.com.co
Thu Oct 9 16:30:20 CEST 2014
Hello,
I was using my integrate today and spend a couple of hours trying to figure
out why I was getting some weird results in my code when using myintegrate
function to do complex integration, after some time decided just to change
the name of the integration dummy variable in the code from 'x' to 'y' and
the code worked perfectly, here is the outpus of what I was using:
> #Find the CDF to find the call prices
> CDF_Merton = function(y,psi_measure){
+ integrand_cdf = function(u_vec,y,psi_measure)
Im(exp(-1i*u_vec*y)*psi_measure(u_vec))/u_vec
+ return(1/2 -
1/pi*Re(myintegrate(integrand_cdf,0,100,y=y,psi_measure=psi_measure)))
+ }
> CDF_Merton(y=0.1,psi_measure=psi)
[1] 0.9368239
>
> CDF_Merton = function(x,psi_measure){
+ integrand_cdf = function(u_vec,x,psi_measure)
Im(exp(-1i*u_vec*x)*psi_measure(u_vec))/u_vec
+ return(1/2 -
1/pi*Re(myintegrate(integrand_cdf,0,100,x=x,psi_measure=psi_measure)))
+ }
> CDF_Merton(x=0.1,psi_measure=psi)
[1] 59.03344
where you can see that both codes are exactly the same except for the dummy
variable used to integrate, does any body know what might be going on here?
Thanks
Felipe Parra
--
Este mensaje de correo electrónico es enviado por Quantil S.A.S y puede
contener información confidencial o privilegiada.
This e-mail is sent by Quantil S.A.S and may contain confidential or
privileged information
[[alternative HTML version deleted]]
More information about the R-help
mailing list