search for: subdivisions

Displaying 20 results from an estimated 109 matches for "subdivisions".

2007 Sep 22
0
error messages
...################################ z<-rvonmises(100,0,1) z<-as.vector(z) x<-rvonmises(100,0,2+cos(z)) x<-as.vector(x) f<-function(x){ k1<-x[1] k2<-x[2] k12<-x[3] g<-x[4] -2*sum(log( exp(k1*cos(x))*integrate(function(y)exp((k2+k12*cos(x))*cos(y)),g,2*pi,subdivisions=1000000)$value /(2*pi*integrate(function(y)besselI(k1+k12*cos(y),0)*exp(k2*cos(y)),g,2*pi,subdivisions=1000000)$value) )) } gr<-function(u){ k1<-u[1] k2<-u[2] k12<-u[3] g<-u[4] grad1<-sum(integrate(function(y)integrate(function(a)(cos(x)-cos(a))*exp(k2*cos(y)+(k1...
2011 Jan 12
1
Integrate and subdivisions limit
...The f(x) is a step function while g(x) is a polynomial. If f(x) (step function) changes its value only few times (5 or 6 'steps') everything is calulated ok(verified results in scrap paper) but if f(x) takes like 800 different values I receive the error "Error in integrate number of subdivisions reached" I did some checks on the internet and I found that I can increase the number of subdivisions (as this is a parameter in integrate(). Thus I raised it from 100 to 1000 (and then to 10000). A. Does this makes the error produced higher or does it only stress the computer? B. When the...
2013 Jul 16
2
Problem following an R bug fix to integrate()
...dora Linux (gcc, clang) and on Solaris machines (sparc, x86), but runs well on all other systems): > fn <- function(x, y) ifelse(x^2 + y^2 <= 1, 1 - x^2 - y^2, 0) > tol <- 1.5e-8 > fy <- function(x) integrate(function(y) fn(x, y), 0, 1, subdivisions = 300, rel.tol = tol)$value > Fy <- Vectorize(fy) > xa <- -1; xb <- 1 > Q <- integrate(Fy, xa, xb, subdivisions = 300, rel.tol = tol)$value Error in integrate(Fy, xa, xb, subdivisions = 300, rel.tol = tol) : roundoff error was detected Ob...
2005 Oct 09
1
enter a survey design in survey2.9
Hi dears, I expect that Mr Thomas Lumley will read this message. I have data from a complexe stratified survey. The population is divide in 12 regions and a region consist to and urban area and rural one. there to region just with urbain area. stratification variable is a combinaison of region and area type (urban/rural) In rural area, subdivision are sample with probabilties proporionnal to
2010 Jul 28
1
error in f(x,...)
Dear all, I tried once to create one variable called bip such that: bip <- cip + (1/f(cip))*fi(f,cip) And this was working. But now, doing the same thing I did before, the software shows me the following message: Error in f(x, ...) : unused argument(s) (subdivision = 2000) I have the variable cip and the variable bip should be created such that: Fn <- ecdf(cip) f <- function(x) {(1 -
2011 Aug 29
1
maximum number of subdivisions reached
Why I am getting Error in integrate(f, x1, x1 + dx) : maximum number of subdivisions reached and can I avoid this? func <- function(y, a, rate, sad){ f3 <- function(z){ f1 <- function(y,a,n){ dpois(y,a*n) } f2 <- function(n,rate){ dexp(n,rate) } f <- function(n){ f1(y,a,n)*f2(n,rate) } r <- 0 r1 <- 1 x1 <- 0 dx <- 20 wh...
2004 Jul 08
1
(PR#7070)
...ug reports. Rembert.DeBlander@econ.kuleuven.ac.be Example 1 ********* > integrate(dnorm,lower=3D"-INF",upper=3D1,-1,7) Error in integrate(dnorm, lower =3D "-INF", upper =3D 1, -1, 7) : invalid parameter values > integrate(dnorm,lower=3D"-INF",upper=3D1,subdivisions=3D100,-1,7) 0.841331 with absolute error < 0.16=20 >integrate(dnorm,lower=3D"-INF",upper=3D1,subdivisions=3D100,rel.tol=3D.M= achine$double.eps^0.25,abs.tol=3D.Machine$double.eps^0.25,-1,7) 0.8413448 with absolute error < 1.5e-05 > pnorm(1,-1,7) [1] 0.6124515 > pnorm(1,0...
2012 Sep 25
1
how to pass a function to a function inside a function
...aratey, these functions work well. However that is not the case if combines together, where certainly I made mistake somewhere when constructing the code. can someone help point out the mistakes for me please? Thanks! Aehan ____________________ intgfun<- function(a,b,c,mu,alpha,xi,upper, ...,subdivisions = 100, rel.tol = .Machine$double.eps^0.25, abs.tol = rel.tol, stop.on.error = TRUE, keep.xy = FALSE, aux = NULL) { x<-vector() fs<-function(x){ temp<-(-xi^(-1))*log(1-xi*(x-mu)/alpha) (((alpha^(-1))*(exp((-(1-xi)*temp)-exp(-temp))))*((a*(x-c)^0.5)+(b*(x-c)))) } return(fs) intgrt...
2005 Sep 16
4
Integrate functions with loops
...form sum(vector^x) i have defined the function with a for loop first - integrandtotest <- function(x) {a<-rep(0,len=2) for (i in 1:2) {a[i]<-t[i]^x} sum(a) } the results gives errors ########### Error in integrate(integrandtotest, lower = 0.1, upper = 2, subdivisions = 10000) : evaluation of function gave a result of wrong length In addition: Warning messages: 1: number of items to replace is not a multiple of replacement length 2: number of items to replace is not a multiple of replacement length ####### I then tried a vector multiplication inste...
2001 Nov 20
1
warning message
...of my own. The function I created for computing the p-value of the dw statistic has a command line like this: »dwf0 <- function(dw,eigen) { carfun <- function(x) { (prod(1+2*(eigen-dw)*1i*x)^(-1/2)-prod(1-2*(eigen-dw)*1i*x)^(-1/2))/(1i*x) } ; 1/2+integrate(f=carfun,lower = 0,upper = Inf, subdivisions=10000)$value/(2*pi) } , with arguments "dw" as a real and "eigen" as a vector. After I run: »dwf0(1.314416,c(3.4420282, 2.6472097, 1.8375986, 1.2928912, 0.6768543, 0.4187899, 0.1058144)) , the console replies: »[1] 0.3576019 »There were 50 or more warnings (use warnings(...
2019 Apr 12
2
integrate over an infinite region produces wrong results depending on scaling
...1, main = "Scaled f", bty = "n") sum(f(seq(-0.08, 0, 1e-6))) * 1e-6 #? Checking by summation: 3.575294 sum(f(seq(-30, 0, 1e-4), numstab = sc)) * 1e-4 # True value, 3.575294 str(integrate(f, -Inf, 0)) # Gives 3.575294 # $ value?????? : num 3.58 # $ abs.error?? : num 1.71e-06 # $ subdivisions: int 10 str(integrate(f, -Inf, 0, numstab = sc)) # $ value?????? : num 1.5 # What?! # $ abs.error?? : num 0.000145 # What?! # $ subdivisions: int 2 It stop at just two subdivisions! The problem is, I cannot try various stabilising multipliers for the function because I have to compute this integ...
2005 Jul 02
3
Telephoning Announcements -- Suggestions?
In the subdivision where I live, we have a well that time to time has problems. Currently, our trustees call me, I take a message, and then call the people on our "phone calling tree" and give them the message. They, in turn, pass the message on to the rest of the residents. We have a few problems with the way this works -- people don't bother to relay the message, or,
2011 Nov 23
2
How to increase precision to handle very low P-values
...urn(pnorm((t-rho01*z)/sqrt(1-rho01^2))*dnorm(z)) } fun2=function(t,z){ return(pnorm(((t-w0*z)/w1-rho01*z)/sqrt(1-rho01^2))*dnorm(z)) } fun3=function(t,z){ return(pnorm((-t-rho01*z)/sqrt(1-rho01^2))*dnorm(z)) } asy=function(t){ z1=2*integrate(function(z){fun1(t,z)},lower=0,upper=t*(1-w1)/w0,subdivisions=1000)$value z2=2*integrate(function(z){fun2(t,z)},lower=t*(1-w1)/w0,upper=t,subdivisions=1000)$value z3=-2*integrate(function(z){fun3(t,z)},lower=0,upper=t,subdivisions=500)$value return(z1+z2+z3) } pvalue <- 1-asy(t) pvalue ########################################### Using this script,...
2007 Jun 28
2
minor flaw in integrate()
...code to replace the old one ### ### [snip] else { if (is.na(lower) || is.na(upper)) stop("a limit is missing") if (lower == upper){ wk <- list("value" = 0, "abs.error" = 0, "subdivisions" = subdivisions, "ierr" = 0 ) } else { if (is.finite(lower)) { inf <- 1 bound <- lower } else if (is.finite(upper)) {...
2009 Dec 18
1
Numerical Integration
...1] && x<fx[2]) return((x-fx[1])/(fx[2]-fx[1])) if(x>fx[2] && x<=fx[3]) return(1) if(x>fx[3] && x<=fx[4]) return((x-fx[4])/(fx[3]-fx[4])) if(x>fx[4]) return(0) } fx<-data[i,j,] reltol<-1e-07 integrate(Vectorize(integrand),0,1,rel.tol=reltol,subdivisions=200)$value It works for most cases, but then, I tried for the triangle fx<-[0.3,0.5,0.5,0.6] and the following error was presented: > integrate(Vectorize(integrand),0,1,rel.tol=reltol,subdivisions=200) [1] 0.5 [1] 0.01304674 [1] 0.9869533 [1] 0.06746832 [1] 0.9325317 [1] 0.1602952 [1] 0.839...
2006 Jun 02
1
doubt with integrate ()
...t;)$y} for (j in (i+1):nbcol) {tdon2<-tdon[,j] tdon21<-subset(tdon2,tdon2!="NA") fctk2<-function(x) {density(tdon21,bandwidth=h[j],kernel="gaussian")$y} diffctk<-function(x) {abs(fctk1(x)-fctk2(x))} }} integrate(diffctk,-Inf,Inf,subdivisions=100)$integral , where: h <- 1.06*ect*(nlc^-0.2); ect <- apply (data,2,sd); nlc <-length of each column in data, excluding NA's. The result gives the error: "Error in integrate (diffctk, -Inf, Inf, subdivisions = 100) : evaluation of function gave a result of...
2013 Feb 05
1
integrate: Don't do this?
...nf <- integrate(fcn, 0, Inf) ## Doc: "Don't do this": f.100 <- integrate(fcn, 0, 100) cbind(f.Inf, f.100) } I get, for n = 9 and n = 10: > HQ2(9) f.Inf f.100 value 0.6531951 0.6531951 abs.error 5.509777e-05 2.931259e-07 subdivisions 10 5 message "OK" "OK" call Expression Expression which indicates that the "Don't do this" works. With n = 10, > HQ2(10) f.Inf f.100 value 3.292159e-05 0.6451915 abs.error 6.121266e-05 4.176584...
2010 Dec 06
3
0.5 != integrate(dnorm,0,20000) = 0
Hello: The example "integrate(dnorm,0,20000)" says it "fails on many systems". I just got 0 from it, when I should have gotten either an error or something close to 0.5. I got this with R 2.12.0 under both Windows Vista_x64 and Linux (Fedora 13); see the results from Windows below. I thought you might want to know. Thanks for all your work in creating
2010 Oct 25
2
Ayuda con una función
...0 1175 1150 1125 1100 1075 1050 1025 1000 975 950 925 900 875 850 825 800 775 750 725 700 675 650 625 600 575 550 525 [31] 500 475 450 425 400 375 350 325 300 275 250 225 200 175 > G(44) Error en integrate(function(x) ppois(x, lamb * L), 0, y) : maximum number of subdivisions reached > G(500) [1] 4499.785 [[alternative HTML version deleted]]
2011 Nov 10
2
performance of adaptIntegrate vs. integrate
...3 tolerance <- 1e-4 # using cubature's adaptIntegrate time1 <- system.time(replicate(1e3, { a <<- adaptIntegrate(integrand, -1, 1, tolerance, 1, max=Nmax) }) ) # using integrate time2 <- system.time(replicate(1e3, { b <<- integrate(integrand, -1, 1, rel.tol=tolerance, subdivisions=Nmax) }) ) time1 user system elapsed 2.398 0.004 2.403 time2 user system elapsed 0.204 0.004 0.208 a$integral > [1] 0.0177241 b$value > [1] 0.0177241 a$functionEvaluations > [1] 345 b$subdivisions > [1] 10 Somehow, adaptIntegrate was using many more function evaluation...