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

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

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 <-

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 .

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

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
In the limit as x goes to infinity, the integrand x f(x) should go to 0 sufficiently fast in order for the integral to be finite. The error indicates that the integrand becomes infinite for large x. Check to ensure that the integrand is correctly specified. I don't understand how you can repla

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

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

Re: [R] Numerical integration problem

2009-09-23 Thread Ravi Varadhan
Hi Marcus, I always use a smaller error tolerance in `integrate' than the default value. I generally use 1.e-07, whereas the default is only about 1.e-04. Sometimes you may also need to increase the number of subdivisions from its default value of 100. Your problem disappears if you use a smalle

Re: [R] numerical integration

2009-09-10 Thread Bert Gunter
My goodness! Did you try ?integrate ? Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Roslina Zakaria Sent: Thursday, September 10, 2009 3:36 PM To: r-help@r-project.org Subject: [R]

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] 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
Hi max, Prof. Ripley is right. Your problem is that you missed a (-) sign in the exponential. Here is a demonstration showing the agreement between numerical and analytical results: gx <- function(x, n) exp(-x) * x^n * log(x) df <- function(n) {integrate(gx, lower=0, upper=Inf, n=n)$val} lib

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
Hi Max, The analytic integral \int _0 ^\Inf exp(-t) t^n log(t) might not converge because the integrand tends to -Inf as t -> 0. So, here is a numerical approach to estimating the derivative of the gamma function: library(numDeriv) fx <- function(x, n) exp(-x) * x^n gf <- function(n) {integrat

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

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