voladoddi
2014-Mar-06 23:56 UTC
[R] Importance Sampling Monte Carlo method for bivariate integration
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. -- Regards and Cheers, Pooja Voladoddi +91-90351 93110 -- View this message in context: http://r.789695.n4.nabble.com/R-Importance-Sampling-Monte-Carlo-method-for-bivariate-integration-tp4686375.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]]
Jeff Newmiller
2014-Mar-07 08:22 UTC
[R] Importance Sampling Monte Carlo method for bivariate integration
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.