# [R] multidimensional integration not over a multidimensionalrectangle

Spencer Graves spencer.graves at pdf.com
Tue Nov 8 04:23:00 CET 2005

```	  The (non)respoonse that I've seen to your question combined with my
own search suggests that R does not yet have a multidimensional
numerical integration function of the generality you desire.

Would you care to tell us more about the problem you are trying to
solve?  For example, if it can be parameterized as an integral over R^k
where the integrand is unimodal, you could approximate the integrand
with a parabolic then do Monte Carlo from the obvious approximation of
that integral by a multivariate normal.  For each selected point, you
compute the ratio of your integrand to the approximating normal density.
Then compute mean and standard deviation of these ratios.  The mean is
the evaluation of the integral, and stdev/N estimates the error.  For

Evans and Swartz (2000) Approximating Integral via Monte Carlo and
Deterministic Methods (Oxford).

hope this helps.
spencer graves

Lynette Sun wrote:

> Hi,
>
> anyone knows about any functions in R can get multidimensional integration
> not over a multidimensional rectangle (not adapt).
>
> For example, I tried the following function f(x,n)=x^n/n!
>
> phi.fun<-function(x,n)
> { if (n==1) {
> 	x
> 	}else{
> 		integrate(phi.fun, lower=0, upper=x, n=n-1)\$value
> 		}
> }
>
> I could get f(4,2)=4^2/2!=8, but failed in f(4,3)=4^3/3! Thanks
>
> Best,
> Lynette
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help

--
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

spencer.graves at pdf.com
www.pdf.com <http://www.pdf.com>
Tel:  408-938-4420
Fax: 408-280-7915

```