Monte Carlo Simulation - University of Notre...

Post on 08-Jul-2020

3 views 0 download

Transcript of Monte Carlo Simulation - University of Notre...

Monte Carlo Simulation

The needle crosses a line if ๐‘ฆ โ‰ค ๐ฟ/2sin(๐œƒ) Q: Whatโ€™s the probability ๐‘ that the needle will intersect on of these lines? โ€ข Let ๐‘ฆ be the distance between the needleโ€™s midpoint and the

closest line, and ๐œƒ be the angle of the needle to the horizontal. โ€ข Assume that ๐‘ฆ takes uniformly distributed values between 0 and

D/2; and ๐œƒ takes uniformly distributed values between 0 and ๐œ‹.

โ€ข Let ๐ฟ = ๐ท = 1.

โ€ข The probability is the ratio of the area of the shaded region to the area of rectangle.

โ€ข ๐‘ = 1

2๐‘ ๐‘–๐‘›๐œƒ๐‘‘๐œƒ๐œ‹0

๐œ‹/2= 2/๐œ‹

Hit and miss method: The volume of the external region is ๐‘‰๐‘’ and the fraction of hits is ๐‘“โ„Ž. Then the volume of the region to be integrated is ๐‘‰ = ๐‘‰๐‘’๐‘“โ„Ž.

Algorithm of Monte Carlo

โ€ข Define a domain of possible inputs.

โ€ข Generate inputs randomly from a probability distribution over the domain.

โ€ข Perform a deterministic computation on the inputs.

โ€ข aggregate the results from all deterministic computation.

Monte Carlo Integration (sampling)

๐ด = lim๐‘โ†’โˆž ๐‘“(๐‘ฅ๐‘–)โˆ†๐‘ฅ

๐‘

๐‘–=1

Where โˆ†๐‘ฅ =๐‘โˆ’๐‘Ž

๐‘, ๐‘ฅ๐‘– = ๐‘Ž + (๐‘– โˆ’ 0.5)โˆ†๐‘ฅ.

๐ด โ‰ˆ๐‘ โˆ’ ๐‘Ž

๐‘ ๐‘“(๐‘ฅ๐‘–)

๐‘

๐‘–=1

Which can be interpreted as taking the average over ๐‘“ in the

interval, i.e., ๐ด โ‰ˆ ๐‘ โˆ’ ๐‘Ž < ๐‘“ >, where < ๐‘“ >= ๐‘“ ๐‘ฅ๐‘–๐‘๐‘–=1

๐‘.