[R] R numerical integration
Hans W Borchers
hwborchers at googlemail.com
Mon Mar 26 17:37:01 CEST 2012
casperyc <casperyc <at> hotmail.co.uk> writes:
>
I don't know what is wrong with your Maple calculations, but I think
you should check them carefully, because:
(1) As Petr explained, the value of the integral will be < 0.5
(2) The approach of Peter still works and returns : 0.4999777
(3) And the same result comes out with Mathematica: 0.49997769...
Hans Werner
> The quadinf command in library pracma still fails when mu=-2.986731 with
> sigma=53415.18.
> While Maple gives me an estimate of 0.5001701024.
> ########################################
> Maple: (for those who are interested)
> myf:=(mu,sigma)->
> evalf(Int(exp(-(x-mu)^2/2/sigma^2)/sigma/sqrt(2*Pi)/(1+exp(-x)),
> x=-infinity..infinity));
> myf(-2.986731, 53415.18 );
> 0.5001701024
> ########################################
>
> These 'mu's and 'sigma's are now random starting points I generated for an
> optimization problem like I have mentioned.
>
> I should really investigate the behavior of this function before I ask R
> doing the integration. As I have mentioned that I had already realized the
> integral is between 0 and 1. And I have had a look at the contour plots of
> different mu and sigma. I am going to 'restrict' mu and sigma to certain
> (small) values, and still get the integral to produce a value between 0
> and 1.
>
> All of your help is much appreciated.
>
> casper
>
More information about the R-help
mailing list