[R] Importance Sampling Monte Carlo method for bivariate integration

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Fri Mar 7 09:22:36 CET 2014


Please read the Posting Guide, which warns you that posting HTML email to this mailing list is not okay. On the off chance that the HTML reaches us at all, it rarely appears to us the way you see it. Please communicate using plain text on this list.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On March 6, 2014 3:56:13 PM PST, voladoddi <pooja.voladoddi at gmail.com> wrote:
>I have the following integral
>
>           (x^-0.5)                                   ;in x=[0.01,1]
>To solve this using Importance Sampling MC integration, one needs to
>select
>an importance pdf that is approximately the same as the function plot
>
>My R code to solve the same is this :
>
>#function 1 - importance sampling
>w <- function(x) dunif(x,0.01,1)/dbeta(x,0.7,1)
>f <- function(x) x^(-0.5)
>X <- rbeta(1000,0.7,1)
>Y <- w(X)*f(X)
>c(mean(Y),var(Y))
>True integral value - 1.8
>Using the Importance Sampling code above - 1.82 (where my importance
>PDF is
>Beta(0.7,1)
>
>which is quite alright so I'm assuming the code is correct.
>
>
>
>
>---------------------------------------------
>However I now have two bivariate functions that look like this in
>intervals
>[x,y] in [-pi,pi] and [x,y] in [-5,5] respectively -
>
>[image: bivariate function 1]
>
>
>Could anyone guide on how to perform MC Importance Sampling for these
>functions? I know I could select two independent distributions however,
>I
>have no idea about how to choose the functions or coding it like the
>way
>above.




More information about the R-help mailing list