Calculate Pi using Monte Carlo - PowerPoint PPT Presentation

1 / 4
About This Presentation
Title:

Calculate Pi using Monte Carlo

Description:

Player throws darts at dartboard of unit radius. Dartboard sits inside of square frame. He's drunk, so darts can hit anywhere in side of frame. ... – PowerPoint PPT presentation

Number of Views:93
Avg rating:3.0/5.0
Slides: 5
Provided by: isc75
Category:

less

Transcript and Presenter's Notes

Title: Calculate Pi using Monte Carlo


1
Calculate Pi using Monte Carlo
  • Stuart Brorson

2
Drunken dart player
  • Player throws darts at dartboard of unit radius.
  • Dartboard sits inside of square frame.
  • Hes drunk, so darts can hit anywhere in side of
    frame.
  • Hits inside/ hits outside pi/4 provides way
    to calculate Pi!
  • Convergence rate?

3
Serial MATLAB code
  • xmin -1 xmax 1 ymin -1 ymax 1
  • samples 5000000
  • hits 0
  • for i1samples
  • hits hits monteCarloTrial(xmin, xmax, ymin,
    ymax)
  • end
  • ratio hits/samples
  • piestimate 4ratio
  • function t monteCarloTrial(xmin, xmax, ymin,
    ymax)x rand()(xmax-xmin) xminy
    rand()(ymax-ymin) yminif (xx yy) lt 1
    t1 inside circleelse t0 outside
    circleend

4
Exercise parallelize using Star-P
  • Whats best way to parallelize a Monte Carlo
    algorithm?
  • How to do it using Star-P?
  • What can go wrong?
  • Can you express this algorithm using
    data-parallel methods?
Write a Comment
User Comments (0)
About PowerShow.com