importance sampling monte carlo methods biostatistics 615
play

Importance sampling Monte-carlo methods Biostatistics 615/815 - PowerPoint PPT Presentation

. . March 14th, 2011 Biostatistics 615/815 - Lecture 16 Hyun Min Kang March 14th, 2011 Hyun Min Kang Importance sampling Monte-carlo methods Biostatistics 615/815 Lecture 16: . . . . . . . Summary . Rejection sampling .


  1. . . March 14th, 2011 Biostatistics 615/815 - Lecture 16 Hyun Min Kang March 14th, 2011 Hyun Min Kang Importance sampling Monte-carlo methods Biostatistics 615/815 Lecture 16: . . . . . . . Summary . Rejection sampling . Importance sampling Integration Introduction . . . . . . . . . 1 / 18 . . . . . . . . . .

  2. . . . . . . . 815 Update . . . . . . . . Hyun Min Kang Biostatistics 615/815 - Lecture 16 March 14th, 2011 . . . Importance sampling . . . . . . . . . Introduction Integration . 2 / 18 . Rejection sampling . Summary Annoucements . Grading . . . . . . . . . . • Midterm will be given by Thursday • All the other homeworks will be given by next Tuesday • Send a brief progress update on the project • Schedule meeting with instructor if needed

  3. . Importance sampling March 14th, 2011 Biostatistics 615/815 - Lecture 16 Hyun Min Kang . Summary . Rejection sampling . 3 / 18 Integration Introduction . . . . . . . . . . . . . . . . . . . Recap : Pseudo-random numbers using rand() #include <iostream> #include <cstdlib> int main(int argc, char** argv) { int n = (argc > 1) ? atoi(argv[1]) : 1; int seed = (argc > 2 ) ? atoi(argv[2]) : 0; srand(seed); // set seed -- same seed, same pseudo-random numbers for(int i=0; i < n; ++i) { std::cout << (double)rand()/RAND_MAX << std::endl; // generate value between 0 and 1 } return 0; }

  4. . . March 14th, 2011 Biostatistics 615/815 - Lecture 16 Hyun Min Kang pseudo-random numbers function in PHP Recap : Good vs. bad random numbers Summary . Rejection sampling . Importance sampling Integration Introduction . . . . . . . . . 4 / 18 . . . . . . . . . . • Images using true random numbers from random.org vs. rand() • Visible patterns suggest that rand() gives predictable sequence of

  5. . . March 14th, 2011 Biostatistics 615/815 - Lecture 16 Hyun Min Kang . Recap : Generating uniform random numbers in C++ Summary . Rejection sampling 5 / 18 Importance sampling Integration Introduction . . . . . . . . . . . . . . . . . . . #include <iostream> #include <boost/random/uniform_int.hpp> #include <boost/random/uniform_real.hpp> #include <boost/random/variate_generator.hpp> #include <boost/random/mersenne_twister.hpp> int main(int argc, char** argv) { typedef boost::mt19937 prgType; // Mersenne-twister : a widely used prgType rng; // lightweight pseudo-random-number-generator boost::uniform_int<> six(1,6); // uniform distribution from 1 to 6 boost::variate_generator<prgType&, boost::uniform_int<> > die(rng,six); // die maps random numbers from rng to uniform distribution 1..6 int x = die(); // generate a random integer between 1 and 6 std::cout << "Rolled die : " << x << std::endl; boost::uniform_real<> uni_dist(0,1); boost::variate_generator<prgType&, boost::uniform_real<> > uni(rng,uni_dist); double y = uni(); // generate a random number between 0 and 1 std::cout << "Uniform real : " << y << std::endl; return 0; }

  6. . . March 14th, 2011 Biostatistics 615/815 - Lecture 16 Hyun Min Kang . . . . . . . . Sampling from complex distributions . Today Summary . . . . . . . . . . Introduction Integration Importance sampling . Rejection sampling 6 / 18 . . . . . . . . . . • Monte-Carlo Methods • Importance Sampling

  7. . . . . . . An example problem . . . . . . . . Calculating Hyun Min Kang Biostatistics 615/815 - Lecture 16 March 14th, 2011 . . . . . . . . . . . . . Introduction . Importance sampling Integration Rejection sampling Monte-Carlo Methods . Informal definition . . 7 / 18 Summary . . . . . . . . . . • Approximation by random sampling • Randomized algorithms to solve deterministic problems approximately. ∫ 1 I = f ( x ) dx 0 where f ( x ) is a complex function with 0 ≤ f ( x ) ≤ 1 The problem is equivalent to computing E [ f ( u )] where u ∼ N (0 , 1) .

  8. . . . B B . Desirable properties of Monte-Carlo methods . . . . . . . . Consistency : Estimates converges to true answer as B increases Unbiasedness : E Minimal Variance Hyun Min Kang Biostatistics 615/815 - Lecture 16 March 14th, 2011 . . . . . . . . . . . . . Introduction Integration Importance sampling . Rejection sampling . Summary The crude Monte-Carlo method . Algorithm . . . 8 / 18 . . . . . . . . . . • Generate u 1 , u 2 , · · · , u B uniformly from U (0 , 1) . • Take their average to estimate θ θ = 1 ˆ ∑ f ( u i ) i =1

  9. . . . . . B B . Desirable properties of Monte-Carlo methods . . . . . . . . Hyun Min Kang Biostatistics 615/815 - Lecture 16 March 14th, 2011 . 8 / 18 . . . . . . . . . . . Introduction Integration Importance sampling . Rejection sampling . . . Summary The crude Monte-Carlo method . Algorithm . . . . . . . . . . • Generate u 1 , u 2 , · · · , u B uniformly from U (0 , 1) . • Take their average to estimate θ θ = 1 ˆ ∑ f ( u i ) i =1 • Consistency : Estimates converges to true answer as B increases • Unbiasedness : E [ˆ θ ] = θ • Minimal Variance

  10. . B . Variance . . . . . . . . B f u du BE f u . B Consistency . . . . . . . . lim B Hyun Min Kang Biostatistics 615/815 - Lecture 16 March 14th, 2011 . B 9 / 18 . . . . . . . . . . Introduction Integration Importance sampling . Rejection sampling . Summary Analysis of crude Monte-Carlo method . Bias . . . . . . . B B . . . . . . . . . . θ ] = 1 E [ f ( u i )] = 1 E [ˆ ∑ ∑ θ = θ i =1 i =1

  11. . . . . Variance . . . . . . . . B B Consistency B . . . . . . . . lim B Hyun Min Kang Biostatistics 615/815 - Lecture 16 March 14th, 2011 B 9 / 18 . Importance sampling Rejection sampling . Summary Analysis of crude Monte-Carlo method . Integration Introduction . . . . . Bias . . . . . B . . . . . B . . . . . . . . . . . . θ ] = 1 E [ f ( u i )] = 1 E [ˆ ∑ ∑ θ = θ i =1 i =1 ∫ 1 1 σ 2 ( f ( u ) − θ ) 2 du = 0 BE [ f ( u ) 2 ] − θ 2 1 =

  12. . . . Variance . . . . . . . . B B Consistency B . . . . . . . . lim Hyun Min Kang Biostatistics 615/815 - Lecture 16 March 14th, 2011 B . B Bias . . . . . . . . . Introduction Integration Importance sampling . Rejection sampling . Summary Analysis of crude Monte-Carlo method . 9 / 18 . . B . . . . . . . . . . . . . . . . θ ] = 1 E [ f ( u i )] = 1 E [ˆ ∑ ∑ θ = θ i =1 i =1 ∫ 1 1 σ 2 ( f ( u ) − θ ) 2 du = 0 BE [ f ( u ) 2 ] − θ 2 1 = ˆ θ = θ B →∞

  13. . . . . . . . . . . . . . . 5 Repeat step 3 and 4 for B times . . h Hyun Min Kang Biostatistics 615/815 - Lecture 16 March 14th, 2011 . . . . . . . . . . . . . Introduction Integration . Importance sampling Rejection sampling Accept-reject (or hit-and-miss) Monte Carlo method . . Algorithm . 10 / 18 Summary . . . . . . . . . . . 1 Define a rectangle R between (0 , 0) and (1 , 1) 2 Set h = 0 (hit), m = 0 (miss). 3 Sample a random point ( x , y ) ∈ R . 4 If f ( x ) < y , then increase h . Otherwise, increase m 6 ˆ θ = h + m | R | .

  14. . . . . . h . Variance . . . . . . . . B Hyun Min Kang Biostatistics 615/815 - Lecture 16 March 14th, 2011 . . . . . . . . . . . . . Introduction Integration Importance sampling . Rejection sampling . Summary Analysis of accept-reject Monte Carlo method . Bias . 11 / 18 . . . . . . . . . . Let u i , v i follow U (0 , 1) . [ ] E [ˆ θ ] = E = θ h + m

  15. . . . . . h . Variance . . . . . . . . B Hyun Min Kang Biostatistics 615/815 - Lecture 16 March 14th, 2011 . . . . . . . . . . . . . Introduction Integration Importance sampling . Rejection sampling . Summary Analysis of accept-reject Monte Carlo method . Bias . 11 / 18 . . . . . . . . . . Let u i , v i follow U (0 , 1) . [ ] E [ˆ θ ] = E = θ h + m σ 2 = θ (1 − θ )

  16. . Summary March 14th, 2011 Biostatistics 615/815 - Lecture 16 Hyun Min Kang method The crude Monte-Carlo method has less variance then accept-rejection B B B B . crude Which method is better? 12 / 18 . Rejection sampling . . . Importance sampling . . . . . . . Introduction Integration . . . . . . . . . . BE [ f ( u ) 2 ] + θ 2 θ (1 − θ ) − 1 σ 2 AR − σ 2 = θ − E [ f ( u )] 2 = ∫ 1 1 = f ( u )(1 − f ( u )) du ≥ 0 0

  17. . . March 14th, 2011 Biostatistics 615/815 - Lecture 16 Hyun Min Kang B B B B . Revisiting The Crude Monte Carlo Summary 13 / 18 Rejection sampling . . . . . . . . Introduction Integration . . Importance sampling . . . . . . . . . . ∫ 1 = E [ f ( u )] = f ( u ) du θ 0 1 ˆ ∑ = f ( u i ) θ i =1 More generally, when x has pdf p ( x ) , if x i is random variable following p ( x ) , ∫ = E p [ f ( x )] = f ( x ) p ( x ) dx θ 1 ˆ ∑ θ = f ( x i ) i =1

  18. . Rejection sampling March 14th, 2011 Biostatistics 615/815 - Lecture 16 Hyun Min Kang B B . Importance sampling Summary . 14 / 18 . Integration . . . Introduction . . . . . . Importance sampling . . . . . . . . . . Let x i be random variable following pdf p ( x ) . [ f ( x ) ] ∫ ∫ f ( x ) θ = f ( x ) dx = p ( x ) g ( x ) du = E g p ( x ) 1 f ( x i ) ˆ ∑ θ = p ( x i ) i =1

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend