Re: [R] Problem with Integrate for NEF-HS distribution

2008-08-26 Thread Ravi Varadhan
Sent: Tuesday, August 26, 2008 1:01 AM To: r-help@r-project.org Subject: [R] Problem with Integrate for NEF-HS distribution I need to calcuate the cumulative probability for the Natural Exponential Family - Hyperbolic secant distribution with a parameter theta between -pi/2 and pi/2

Re: [R] Problem with Integrate for NEF-HS distribution

2008-08-26 Thread xia wang
: [R] Problem with Integrate for NEF-HS distribution Date: Tue, 26 Aug 2008 11:59:44 -0400 Hi, Simply re-write your integrand as follows: integrand - function(X) {0.5 * cos(theta) * 2 / (exp(-pi*X/2 - X*theta) + exp(pi*X/2 - X*theta)) } Now the problem goes away. theta - -1

Re: [R] Problem with Integrate for NEF-HS distribution

2008-08-26 Thread xia wang
distribution To: [EMAIL PROTECTED] Shouldn't you define integrand - function(X,theta) .. and not integrand - function(X) . --- On Tue, 26/8/08, xia wang [EMAIL PROTECTED] wrote: From: xia wang [EMAIL PROTECTED] Subject: [R] Problem with Integrate for NEF-HS distribution

Re: [R] Problem with Integrate for NEF-HS distribution

2008-08-26 Thread Ravi Varadhan
Varadhan Cc: r-help@r-project.org Subject: RE: [R] Problem with Integrate for NEF-HS distribution Thanks so much. It works well in my MCMC sampling. May I know why re-writing the integrand can solve the problem? I have been thinking it was the skewness of the distribution brought the error

Re: [R] Problem with Integrate for NEF-HS distribution

2008-08-26 Thread xia wang
Got it. Thanks so much! Xia From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: r-help@r-project.org Subject: RE: [R] Problem with Integrate for NEF-HS distribution Date: Tue, 26 Aug 2008 14:50:18 -0400 Try the following: sech-function(X) 2/(exp(-X)+exp(X)) your.integrand

Re: [R] Problem with Integrate for NEF-HS distribution

2008-08-26 Thread Moshe Olshansky
) } Date: Tue, 26 Aug 2008 00:49:02 -0700 From: [EMAIL PROTECTED] Subject: Re: [R] Problem with Integrate for NEF-HS distribution To: [EMAIL PROTECTED] Shouldn't you define integrand - function(X,theta) .. and not integrand - function(X) . --- On Tue, 26/8/08, xia

[R] Problem with Integrate for NEF-HS distribution

2008-08-25 Thread xia wang
I need to calcuate the cumulative probability for the Natural Exponential Family - Hyperbolic secant distribution with a parameter theta between -pi/2 and pi/2. The integration should be between 0 and 1 as it is a probability. The function integrate works fine when the absolute value of