Re: [R] Numerical integration with R

2014-06-14 Thread David Winsemius
On Jun 14, 2014, at 7:40 AM, Christofer Bogaso wrote: > Hi again, > > I was tying to solve following 2-fold integration with package cubature. > However spending approximately 2 hours it failed to generate any number. I > am using latest R with win-7 machine having 4gb ram. > >> library(cubatur

[R] Numerical integration with R

2014-06-14 Thread Christofer Bogaso
Hi again, I was tying to solve following 2-fold integration with package cubature. However spending approximately 2 hours it failed to generate any number. I am using latest R with win-7 machine having 4gb ram. > library(cubature) > f <- function(x) { + z1 <- x[1] + z2 <- x[2] + + Rho = 1 + + L <

Re: [R] numerical integration of a bivariate function

2013-04-22 Thread Berend Hasselman
On 22-04-2013, at 15:04, Hicham Mezouara wrote: > > hello > I work on > the probabilities of bivariate normal distribution. I need > integrate the > following function. > f (x, y) = exp [- (x ^ 2 + y ^ 2 + x * y)] with - ∞ ≤ x ≤ > 7.44 and - ∞ ≤ y ≤ 1.44 , either software R or matlab Versio

Re: [R] numerical integration of a bivariate function

2013-04-22 Thread R. Michael Weylandt
On Mon, Apr 22, 2013 at 2:04 PM, Hicham Mezouara wrote: > hello > I work on > the probabilities of bivariate normal distribution. I need > integrate the > following function. > f (x, y) = exp [- (x ^ 2 + y ^ 2 + x * y)] with - ∞ ≤ x ≤ > 7.44 and - ∞ ≤ y ≤ 1.44 , either software R or matlab Ver

[R] numerical integration of a bivariate function

2013-04-22 Thread Hicham Mezouara
hello I work on the probabilities of bivariate normal distribution. I need integrate  the following function. f (x, y) = exp [- (x ^ 2 + y ^ 2 + x * y)] with - ∞ ≤ x ≤ 7.44 and - ∞ ≤ y ≤ 1.44   , either software R or  matlab Version R 2009a Thank you for helping me Regards

Re: [R] numerical integration

2012-05-23 Thread Hans W Borchers
Michael Meyer yahoo.com> writes: > Check your logic. The following lines show that integrate *does* return the correct values: a = 0.08 # alpha M <- function(j,s){ return(exp(-j*a*s)) } A <- matrix(NA, 5, 5) for (i in 1:5) { for (j in i:5) { f <-

[R] numerical integration

2012-05-23 Thread Michael Meyer
Greetings, Sorry, the last message was sent by mistake! Here it is again: I encounter a strange problem computing some numerical integrals on [0,oo). Define $$ M_j(x)=exp(-jax) $$ where $a=0.08$. We want to compute the $L^2([0,\infty))$-inner products $$ A_{ij}:=(M_i,M_j)=\int_0^\infty M_i(x)M_j(x

Re: [R] Numerical integration of a two dimensional function over a disk

2012-05-09 Thread yingfu xie
y 8, 2012 1:44 PM Subject: Re: [R] Numerical integration of a two dimensional function over a disk "Simply impossible" seems an odd description for a technique described in every elementary calculus text under the heading "integration in cylind

Re: [R] Numerical integration of a two dimensional function over a disk

2012-05-08 Thread Jeff Newmiller
"Simply impossible" seems an odd description for a technique described in every elementary calculus text under the heading "integration in cylindrical coordinates". --- Jeff NewmillerThe .

[R] Numerical integration of a two dimensional function over a disk

2012-05-08 Thread yingfu xie
Hello, there!   Basically my problem is very clear. I would like to take a (numerical) integration of a function f(x,y) which can be quite complex of x and y, over a disk (x-a)^2+(y-b)^2<= r^2 (with r constant). However, after some search in R, I just cannot find a function in R that suits my pu

[R] Numerical integration again

2012-04-18 Thread casperyc
ine though. I am using 'quadinf' to avoid some large parameters that will cause the function to return an error or return an inaccurate value, discussed in http://r.789695.n4.nabble.com/R-numerical-integration-td4500095.html R-numerical-integration Any comments or suggestions? Thank

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
arial Science, University of Kent ### -- View this message in context: http://r.789695.n4.nabble.com/R-numerical-integration-tp4500095p4503766.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https:

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

[R] R numerical integration

2012-03-23 Thread casperyc
this message in context: http://r.789695.n4.nabble.com/R-numerical-integration-tp4500095p4500095.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] Numerical integration

2011-07-01 Thread nany23
thanks for the Italian! I apologize for my previuos explanation which was not clear actually there are two "k" parameters, so I change one them; let's put it this way /# these are the 3 parameters a<- 414.566 b<- 345.5445 g<- -0.9695679 xstar<- 1397.923 *m<-100* #I create a vector pars <-

Re: [R] Numerical integration

2011-07-01 Thread nany23
thank you very much for your suggestion! I tried to do that with the psf I need to use: the 3 parameters Lognormal. I did that with a single xstar and a single triplet of parameters to check it works.[I put some numbers to make it woks , but actually they comes from statistical analysis] /# the

Re: [R] Numerical integration

2011-06-30 Thread Dennis Murphy
Hi: You could write the function this way: f <- function(x, xstar, k) dnorm(x) * k * x * (x >= xstar) where the term in parentheses is a logical. For any x < xstar, f will be zero by definition. Substitute your density in for dnorm(). To integrate over a grid of (xstar, k) values, you could try

[R] Numerical integration

2011-06-29 Thread nany23
Hello! I know that probably my question is rather simple but I' m a very beginner R-user. I have to numerically integrate the product of two function A(x) and B(x). The integretion limits are [X*; +inf] Function A(x) is a pdf function while B(x)=e*x is a linear function whose value is equal to

Re: [R] numerical integration and 'non-finite function value' error

2011-06-24 Thread Adan_Seb
The domain of the beta distribution as defined in R is 0 <= x <= 1 and as shown by David Winsemius it is undefined outside [0,1]. But thats sort of the question I have. To elaborate, I have a variable with 0 as its natural lower limit but can assume any positive number as an upper limit. So its do

Re: [R] numerical integration and 'non-finite function value' error

2011-06-23 Thread David Winsemius
On Jun 23, 2011, at 8:55 AM, Adan_Seb wrote: Here is a self-contained example of my problem. set.seed(100) x = rbeta(100, 10.654, 10.439) # So the shape parameters and the exteremes are a = 10.654 b = 10.439 xmax = 1 xmin = 0 # Using the non-standardized form (as in my application and this s

Re: [R] numerical integration and 'non-finite function value' error

2011-06-23 Thread Adan_Seb
Here is a self-contained example of my problem. set.seed(100) x = rbeta(100, 10.654, 10.439) # So the shape parameters and the exteremes are a = 10.654 b = 10.439 xmax = 1 xmin = 0 # Using the non-standardized form (as in my application and this shouldn't make any difference) of the # Beta densi

Re: [R] numerical integration and 'non-finite function value' error

2011-06-22 Thread Ravi Varadhan
Sent: Wednesday, June 22, 2011 6:46 PM To: r-help@r-project.org Subject: [R] numerical integration and 'non-finite function value' error Dear R users, I have a question about numerical integration in R. I am facing the 'non-finite function value' error while

[R] numerical integration and 'non-finite function value' error

2011-06-22 Thread Adan_Seb
Dear R users, I have a question about numerical integration in R. I am facing the 'non-finite function value' error while integrating the function xf(x) using 'integrate'. f(x) is a probability density function and assumed to follow the three parameter (min = 0) beta

Re: [R] Numerical integration

2010-11-17 Thread David Winsemius
On Nov 17, 2010, at 6:44 AM, Eduardo de Oliveira Horta wrote: 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

[R] Numerical integration

2010-11-17 Thread Eduardo de Oliveira Horta
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

Re: [R] Numerical Integration

2009-12-18 Thread William Dunlap
> -Original Message- > From: Julio Rojas [mailto:jcredbe...@ymail.com] > Sent: Friday, December 18, 2009 9:06 AM > To: William Dunlap; r-help@r-project.org > Subject: RE: [R] Numerical Integration > > Thanks a lot William. I'm sorry about the syntax problem. I

Re: [R] Numerical Integration

2009-12-18 Thread Julio Rojas
ain, thanks. One last question: Is there a way to use "approx" as the integrand? Best regards. Julio --- El vie 18-dic-09, William Dunlap escribió: > De: William Dunlap > Asunto: RE: [R] Numerical Integration > A: "Julio Rojas" > Fecha: viernes, 18 diciembre

[R] Numerical Integration

2009-12-18 Thread Julio Rojas
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

Re: [R] Numerical integration problem

2009-09-23 Thread Ravi Varadhan
rg Subject: [R] Numerical integration problem Hi there I'm trying to construct a model of mortality risk in 2D space that requires numerical integration of a hazard function, for which I'm using the integrate function. I'm occasionally encountering parameter combinations that cause inte

[R] Numerical integration problem

2009-09-23 Thread Marcus Rowcliffe
Hi there I'm trying to construct a model of mortality risk in 2D space that requires numerical integration of a hazard function, for which I'm using the integrate function. I'm occasionally encountering parameter combinations that cause integrate to terminate with error "Error in integrate... the i

Re: [R] numerical integration

2009-09-10 Thread Bert Gunter
] numerical integration Hi r-users, Can I do a numerical integration in R to solve for F(z)- integral_0^z {f(t) dt} = 0 where F(z) is the CDF and f(t) is the pdf? What package can I use? Thank you so much for any help given. [[alternative HTML version deleted

[R] numerical integration

2009-09-10 Thread Roslina Zakaria
Hi r-users,   Can I do a numerical integration in R to solve for F(z)- integral_0^z {f(t) dt} = 0 where F(z) is the CDF and f(t) is the pdf?  What package can I use?   Thank you so much for any help given. [[alternative HTML version deleted]] ___

Re: [R] Numerical Integration Problems

2009-01-08 Thread Christos Argyropoulos
Hi, You may want to try the double exponential transformation on the numerator and the denominator on this one. The method is described in detail here: http://projecteuclid.org/DPubS?service=UI&version=1.0&verb=Display&handle=euclid.prims/1145474600 If you want to give it a shot outside

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

[R] R: numerical integration problems

2009-01-02 Thread Allan Clark
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 experimentation on a trivial example. example ==

Re: [R] Numerical Integration in 1D

2008-03-07 Thread Prof Brian Ripley
On Fri, 7 Mar 2008, Max wrote: > Prof Brian Ripley formulated on Friday : >> On Fri, 7 Mar 2008, Max wrote: >> >>> Dear UseRs, >>> >>> I'm curious about the derivative of n!. >>> >>> We know that Gamma(n+1)=n! So when on takes the derivative of >>> Gamma(n+1) we get Int(ln(x)*exp(-x)*x^n,x=0..Inf)

Re: [R] Numerical Integration in 1D

2008-03-07 Thread Ravi Varadhan
le/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Max Sent: Friday, March 07, 2008 1:41 PM To: [EMAIL PROTECTED] Subject: [R] Numerical Integration in 1D Dear UseRs, I'm cu

Re: [R] Numerical Integration in 1D

2008-03-07 Thread Max
Prof Brian Ripley formulated on Friday : > On Fri, 7 Mar 2008, Max wrote: > >> Dear UseRs, >> >> I'm curious about the derivative of n!. >> >> We know that Gamma(n+1)=n! So when on takes the derivative of >> Gamma(n+1) we get Int(ln(x)*exp(-x)*x^n,x=0..Inf). >> >> I've tried code like >> >>> in

Re: [R] Numerical Integration in 1D

2008-03-07 Thread Ravi Varadhan
Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Max Sent: Friday, March 07, 2008 1:41 PM To: [EMAIL PROTECTED] Subject: [R] Numerical Integration in 1D Dear UseRs, I'm curious about the derivative of n!. We know that Gamma(n+

Re: [R] Numerical Integration in 1D

2008-03-07 Thread Prof Brian Ripley
On Fri, 7 Mar 2008, Max wrote: > Dear UseRs, > > I'm curious about the derivative of n!. > > We know that Gamma(n+1)=n! So when on takes the derivative of > Gamma(n+1) we get Int(ln(x)*exp(-x)*x^n,x=0..Inf). > > I've tried code like > >> integrand<-function(x) {log(x)*exp(x)*x^n} >> integrate(inte

[R] Numerical Integration in 1D

2008-03-07 Thread Max
Dear UseRs, I'm curious about the derivative of n!. We know that Gamma(n+1)=n! So when on takes the derivative of Gamma(n+1) we get Int(ln(x)*exp(-x)*x^n,x=0..Inf). I've tried code like > integrand<-function(x) {log(x)*exp(x)*x^n} > integrate(integrand,lower=0,upper=Inf) It seems that R doesn

Re: [R] numerical integration of a ftn of 2 variables

2008-02-21 Thread Berend Hasselman
Chris Rhoads wrote: > > > I wish to find the root of a function of two variables that is defined by > an integral which must be > evaluated numerically. > > So the problem I want to solve is of the form: Find k such that f(k)=0, > where f(y) = int_a^b > g(x,y) dx. Again, the integral > invo

Re: [R] numerical integration of a ftn of 2 variables

2008-02-21 Thread Paul Smith
On Tue, Feb 19, 2008 at 11:07 PM, Chris Rhoads <[EMAIL PROTECTED]> wrote: > To start, let me confess to not being an experienced programmer, although I > have used R fairly > extensively in my work as a > graduate student in statistics. > > I wish to find the root of a function of two variable

[R] numerical integration of a ftn of 2 variables

2008-02-19 Thread Chris Rhoads
Dear R gurus, To start, let me confess to not being an experienced programmer, although I have used R fairly extensively in my work as a graduate student in statistics. I wish to find the root of a function of two variables that is defined by an integral which must be evaluated numerically.