[R] Multidimensional Integration over arbitrary sets

Saptarshi Guha sapsi at pobox.com
Wed Feb 14 00:42:32 CET 2007


Hi,
	Thanks! That should do it.
Saptarshi Guha | sapsi at pobox.com | http://www.stat.purdue.edu/~sguha

On Feb 13, 2007, at 3:56 PM, Ravi Varadhan wrote:

> Hi,
>
> By defining your function appropriately (e.g. using indicator  
> functions),
> you can make "adapt" work:
>
> myfunc <- function(x) {
> x[1]*x[2] * (x[1] >= x[2])
> }
> # Exact answer is 1/8
>
>> library(adapt)
>> adapt(2, lo=c(0,0), up=c(1,1), functn=myfunc)
>       value      relerr      minpts      lenwrk       ifail
>   0.1250612 0.009995054        5907        1123           0
>
>
> Ravi.
>
> ---------------------------------------------------------------------- 
> ------
> -------
>
> Ravi Varadhan, Ph.D.
>
> Assistant Professor, The Center on Aging and Health
>
> Division of Geriatric Medicine and Gerontology
>
> Johns Hopkins University
>
> Ph: (410) 502-2619
>
> Fax: (410) 614-9625
>
> Email: rvaradhan at jhmi.edu
>
> Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/ 
> Varadhan.html
>
>
>
> ---------------------------------------------------------------------- 
> ------
> --------
>
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Saptarshi Guha
> Sent: Tuesday, February 13, 2007 3:34 PM
> To: R-Help
> Subject: [R] Multidimensional Integration over arbitrary sets
>
> Hi,
> 	I need to integrate a 2D function over range where the limits depend
>
> on the other e.g integrate f(x,y)=x*y over {x,0,1} and {y,x,1}.
> 	i.e \int_0^1 \int_x^1 xy dydx
>
> 	I checked adapt but it doesn't seem to help here. Are they any
> packages for this sort of thing?
> 	I tried RSitesearch but couldn't find the answer to this.
> 	Many thanks for you help.
> 	Regards
> 	Saptarshi
>
> Saptarshi Guha | sapsi at pobox.com | http://www.stat.purdue.edu/~sguha
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list