similar to: minor flaw in integrate()

Displaying 20 results from an estimated 6000 matches similar to: "minor flaw in integrate()"

2012 Sep 25
1
how to pass a function to a function inside a function
Hi, I'm trying to compile two functions into one function. the first funtion is called 'fs' which is self-made function, another function is from the built-in 'integration' function that is copy-paste-edited. If built separatey, these functions work well. However that is not the case if combines together, where certainly I made mistake somewhere when constructing the code.
2004 Jul 08
1
(PR#7070)
> version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 1 minor 7.1 year 2003 month 06 day 16 language R Bug: integrate(f,lower,upper,extra_args) where f <- function(x,extra_args) { body } integrate doesn't pass the extra arguments when calling f. As a first check of this finding I integrated dnorm from
2013 Jul 16
2
Problem following an R bug fix to integrate()
I have been told by the CRAN administrators that the following code generated an error on 64-bit Fedora 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,
2009 Dec 18
1
Numerical Integration
Dear @ll. I have to calculate numerical integrals for triangular and trapezoidal figures. I know you can calculate the exactly, but I want to do it this way to learn how to proceed with more complicated shapes. The code I'm using is the following: integrand<-function(x) { print(x) if(x<fx[1]) return(0) if(x>=fx[1] && x<fx[2]) return((x-fx[1])/(fx[2]-fx[1]))
2019 Apr 12
2
integrate over an infinite region produces wrong results depending on scaling
Dear all, This is the first time I am posting to the r-devel list. On StackOverflow, they suggested that the strange behaviour of integrate() was more bug-like. I am providing a short version of the question (full one with plots: https://stackoverflow.com/q/55639401). Suppose one wants integrate a function that is just a product of two density functions (like gamma). The support of the
2011 Nov 10
2
performance of adaptIntegrate vs. integrate
Dear list, [cross-posting from Stack Overflow where this question has remained unanswered for two weeks] I'd like to perform a numerical integration in one dimension, I = int_a^b f(x) dx where the integrand f: x in IR -> f(x) in IR^p is vector-valued. integrate() only allows scalar integrands, thus I would need to call it many (p=200 typically) times, which sounds suboptimal. The
2007 Feb 27
1
Additional args to fun in integrate() not found?
Hello, fellow Rdicts, I have the code for the program below. I need to integrate a function of "x" and "p". I use integrate to integrate over "x" and pass "p" as an additional argument. "p" is specified and given default value in the argument list. Still, integrate() cannot read "p", unless I explicitly insert a numeric value in the
2004 Jul 08
0
a not-a-bug report on integrate (PR#7070)
Rembert.DeBlander@econ.kuleuven.ac.be wrote: >>version > PLEASE: a) Use a sensible subject line b) Please post only post bug reports if you are sure it is a bug (and here it is not a bug!) c) Check the recent R version (1.9.1) if posting bugs, not an outdated one! d) Only named arguments are passed through the ... argument: integrate(dnorm, lower=-Inf, upper=3, mean=-1, sd=7) Uwe
2011 Aug 03
1
Case-by-case tolerance needed for successful integrate()
Hello, We are trying to use R to simulate a model based on parameters 'a' and 'b'. This involves the following integration: model<-function(s,x,a,b)(exp(-s*x*10^-5.5)*(s^(a-1)*(1-s)^(b-1))) g<- function(x,a,b){ out<-c() for (i in 1:length(x)){ out[i]<-1- (integrate(model,0,1,x[i],a,b)$value / beta(a,b)) } out } x<-
2009 Jan 05
1
transform R to C
Dear R users, i would like to transform the following function from R-code to C-code and call it from R in order to speed up the computation because in my other functions this function is called many times. `dgcpois` <- function(z, lambda1, lambda2) { `f1` <- function(alpha, lambda1, lambda2) return(exp(log(lambda1) * (alpha - 1) - lambda2 * lgamma(alpha))) `f2` <-
2012 Apr 26
2
ErrError in f(x, ...) : object 'g.' not found
Hi , R is a new language for me so sorry in advance if this error is to basic for posting. I have tried the R manual and search online for quite a few, if anyone could help i would be very thankful. Here is my code. kappa = 1.1 theta = 0.1 sigma = 0.4 rho = -0.6 v0 = 0.2 r = 0.05 T = 0.5 s0 = 1 K = 0.5 type = 1 Hestoncall = function(kappa,theta,sigma,rho,v0,r,T,s0,K,type) { u = 0.5 b
2012 Mar 29
1
Error, Variable is Missing
Hi, I am writing a function to plot a pdf of a distribution, GNL.pdf.fn = function(x,mu,sigma,alpha,beta,rho) { y = x-rho*mu cf.fn = function(s){ cplex = complex(1,0,1) temp1 = alpha*beta*exp(-sigma*s^2/2) temp2 = (alpha-cplex*s)*(beta+cplex*s) out = (temp1/temp2)^rho out } temp.fn = function(s){ (Mod(cf.fn(s)))*cos(Arg(cf.fn(s))-s*y) } int.fn =
2005 Jan 29
2
Name conflicts when passing arguments for one function to another
I am fairly new to R. I find it surprising that f <- function(x,a) {x-a} uniroot(f, c(0,1), a=.5) works, but integrate(f, 0, 1, a=.5) gives an error: Error in integrate(f, 0, 1, a = 0.5) : argument 4 matches multiple formal arguments What is the best way of avoiding such surprises? Is there a way of telling integrate() that the 'a' argument is for f()? If I wrote my own function
2011 Jan 12
1
Integrate and subdivisions limit
Dear all, I have some issues with integrate in R thus I would like to request your help. I am trying to calculate the integral of f(x)*g(x). 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
2010 Nov 17
2
Numerical integration
Hi! I was wondering if there are any other functions for numerical integration, besides 'integrate' from the stats package, but which wouldn't require the integrand to be vectorized. Oh, and must be capable of integrating over (-inf,+inf). Thanks in advance, Eduardo Horta [[alternative HTML version deleted]]
2012 Apr 18
0
Numerical integration again
Hi all, Here is an integration function require(pracma) # for 'quadinf' myint=function(j) { quadinf(function(x) (1/(1+exp(-x)))^j*(1-1/(1+exp(-x)))^(k-j)*dnorm(x,mu,casigma),-Inf,Inf) } in any optimization routine. It works fine most of the time but failed with some particular sets of values, say one of the following: k=20 mu=-1.978295 casigma=0.008326927 >
2005 Sep 16
4
Integrate functions with loops
Hi i am having a problem with the 'integrate' function the function i want to integrate has the 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 =
2006 Jun 02
1
doubt with integrate ()
Dear members, I'm getting an error with the "integrate" function. Searching in the r-help archives, I think this may have something to do with the function (it is not returning a vector but a number), but I don't see exactly what. The function to integrate was defined with a for loop first: for (i in 1:(nbcol-1)) {tdon1<-tdon[,i]
2013 Feb 05
1
integrate: Don't do this?
When I run the following function HQ2 <- function(n) { nv <- 6 * sqrt(n) fcn <- function(z) { pchisq(z^2 / 36, n - 1) * dnorm(nv - z) } ## I want the integral from 0 to infinity: f.Inf <- 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
2008 Sep 30
2
R's integrate function
Hello, I am trying to use R's integrate function to calculate the following integral for z=423: integrate(function(y,z){ sapply(y, function(y,z){ integrate(function(x,z) 1/x*dbeta(0.01,x/(0.005/1.005),(1-x)/(0.005/1.005))*dbeta(y,x/(0.005/1.005),(1-x)/(0.005/1.005))*(1-y)^z,0,1,423)$value }) },0,1,423)$value but I receive an error message saying that the maximum number of subdivisions is