s-news
[Top] [All Lists]

Re: (corrected) Double integration(summary)

To: "Dr. Takashi Kikuchi" <takashi.kikuchi@st-hughs.oxford.ac.uk>, s-news@wubios.wustl.edu
Subject: Re: (corrected) Double integration(summary)
From: Diego Kuonen <Diego@Kuonen.com>
Date: Wed, 27 Jun 2001 23:39:51 +0200
Organization: Chair of Statistics $\subset$ DMA \@ EPFL
References: <5D7F6EA633D0344EAD76552F7E49446CD43626@GOAEVS01.abf.ad.airborne.com> <003001c0ff47$7bd82e60$a6e501a3@ox.ac.uk> <3B3A4A02.4C1D7992@Kuonen.com>
Reply-to: Diego@Kuonen.com
Diego Kuonen wrote:
> 
> First, let us start with the proposed Monte Carlo integration.  The analytical
> solution is 20*log(5)/6 = 5.364793, hence using the following function ...

Using always transformations down to [0,1]^2 for my variables, I forgot
to multiply the MC estimates by the volume of the region of integration.
The corrected MC function becomes

MC.integrate.2D <- function(fct, low=c(-1,1), upp=c(1,1),
                            npoints=100, exact.value=NULL)
  {
  points.x<-runif(n=npoints, min=low[1], max=upp[1])
  points.y<-runif(n=npoints, min=low[2], max=upp[2])
  approx.tmp <- fct(points.x, points.y)
  V.tmp <- diff(c(low[1], upp[1])) * diff(c(low[2], upp[2]))
  approx <- mean(approx.tmp) * V.tmp
  varapprox <- var(approx.tmp) * V.tmp
  if(!is.null(exact.value)) {
    cat("To achieve an error of 0.0001 you need at least",
         floor(abs(varapprox - exact.value^2)/(0.0001^2)),
         "points.\n")
    }
  approx
  }

Nevertheless, my previous comments remain: I do not feel 
comfortable using MC methods.

Greets

  Diego Kuonen


-- 
Diego DOT Kuonen AT epfl DOT ch      diego AT kuonen DOT com
http://stat.kuonen.com                 http://www.Statoo.com 
`If you can imagine it, you can achieve it; if you can dream 
it, you can become it.'              Powered by Open Source!

<Prev in Thread] Current Thread [Next in Thread>