On Sun, 8 Jan 2023 05:24:05 +0200
Leonard Mada via R-help wrote:
> pracma::integral(function(x) x^3 / sin(x), -pi/2, pi/2 )
> # 3.385985
Note that at least one implementation used by pracma::integral has the
same problem:
pracma::integral(function(x) x^3/sin(x), -pi/2, pi/2, no_intervals=7)
# [
`subdivisions` is the maximum number of subintervals. Looking here
https://github.com/wch/r-source/blob/79298c499218846d14500255efd622b5021c10ec/src/appl/integrate.c#L1275
I'm not surprised that changing `subdivisions` has no effect on the
outcome. The integration method from {pracma} might work,
You're dividing 0 by 0, giving you NaN, perhaps you should try
function(x) ifelse(x == 0, 0, x^3/sin(x))
On Sat, Jan 7, 2023, 22:24 Leonard Mada via R-help
wrote:
> Dear List-Members,
>
> I encounter a problem while trying to integrate the following function:
>
> integrate(function(x) x^3 / sin
Dear List-Members,
I encounter a problem while trying to integrate the following function:
integrate(function(x) x^3 / sin(x), -pi/2, pi/2)
# Error in integrate(function(x) x^3/sin(x), -pi/2, pi/2) :
# non-finite function value
# the value should be finite:
curve(x^3 / sin(x), -pi/2, pi/2)
int
>Error in integrate(fx[[2]], 0.056, 1) :
> maximum number of subdivisions reached
>
> Can anyone help?
At the risk of longer integration time, look at the 'subdivisions' argument in
?integrate and consider increasing it?
S Ellison
Hello,
The following code of mine is giving the error:
Error in integrate(fx[[2]], 0.056, 1) :
maximum number of subdivisions reached
Can anyone help?
Thanks and Regards.
Swagato
--
fv<-vector("list")
fx<-vector("list")
v<-0
c<-0
n<-0
NOV<-0
i<-0
while(n<200){
fv[
can be computed analytically, so you
are left with integral from -10 (or -15) to your upper bound and this should be
all right for numerical integration.
--- On Wed, 27/8/08, xia wang <[EMAIL PROTECTED]> wrote:
> From: xia wang <[EMAIL PROTECTED]>
> Subject: RE: [R] Problem w
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.integr
12:59 PM
To: Ravi 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 broug
[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 wang <[EMA
; Subject: RE: [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*t
CTED] On
Behalf Of xia wang
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 -
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 th
?try
This will catch the error and let you take alternative action.
On 9/21/07, Dan Rabosky <[EMAIL PROTECTED]> wrote:
>
> Hello -
>
> I am having a problem with the function 'integrate'. I am running R
> on OSX (R 2.5.1).
>
> I am trying to suppress the error message when 'integrate' attempts
>
Hello -
I am having a problem with the function 'integrate'. I am running R
on OSX (R 2.5.1).
I am trying to suppress the error message when 'integrate' attempts
to integrate across a parameter set giving a non-finite function
value. I'm using it in a MCMC / simulated annealing algorithm
Hello!
I have a problem with integrate() in my function nctspa(). Integrate
produces an error message "evaluation of function gave a result of
wrong length". I don't know what that means. Could anyone suggest me
what is wrong with my function?
These are the examples of function calls that work OK
16 matches
Mail list logo