Post on 08-Jul-2020
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
๐.