Re: [R] R numerical integration

2012-03-26 Thread Hans W Borchers
casperyc 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 c

Re: [R] R numerical integration

2012-03-25 Thread casperyc
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)

Re: [R] R numerical integration

2012-03-24 Thread peter dalgaard
On Mar 24, 2012, at 09:46 , Petr Savicky wrote: > Integrating with infinite limits is necessarily a heuristic. ...as is numerical integration in general. In the present case, the infinite limits are actually only half the problem. The integrate() function is usually quite good at dealing with

Re: [R] R numerical integration

2012-03-24 Thread Petr Savicky
On Fri, Mar 23, 2012 at 01:27:57PM -0700, casperyc wrote: > Hi all, > > Is there any other packages to do numerical integration other than the > default 'integrate'? > > Basically, I am integrating: > > integrate(function(x) dnorm(x,mu,sigma)/(1+exp(-x)),-Inf,Inf)$value > > The integration is o

Re: [R] R numerical integration

2012-03-24 Thread Hans W Borchers
Hans W Borchers googlemail.com> writes: > > casperyc hotmail.co.uk> writes: > > > Is there any other packages to do numerical integration other than the > > default 'integrate'? > > Basically, I am integrating: > > > > integrate(function(x) dnorm(x,mu,sigma)/(1+exp(-x)),-Inf,Inf)$value > > >

Re: [R] R numerical integration

2012-03-24 Thread Hans W Borchers
casperyc hotmail.co.uk> writes: > Is there any other packages to do numerical integration other than the > default 'integrate'? > Basically, I am integrating: > > integrate(function(x) dnorm(x,mu,sigma)/(1+exp(-x)),-Inf,Inf)$value > > The integration is ok provided sigma is >0. > However, when m

Re: [R] R: numerical integration problems

2009-01-02 Thread Duncan Murdoch
On 02/01/2009 6:37 AM, Allan Clark wrote: hello all happy new year and hope you r having a good holiday. i would like to calculate the expectation of a particular random variable and would like to approximate it using a number of the functions contained in R. decided to do some experimentat