In: Math
Let S be the square centered at the origin with sides of length 2, and C be the unit circle centered at the origin.
(a) If you randomly throw a point on S, what is the probability that it will lie in C?
Ans: 0.785
(b) Describe how you could use simulation to estimate the probability in part (a).
(c) How can you use simulation to estimate a?
For part b and c, there maybe a need to generate random variables for the simulation by Box-Muller, Accept/Reject or importance sampling. Any help on b and c will be appreciated !
a)
probability = area of circle/ area of square = pi/4 = 0.785
b)
we can generate two random random numbers x and y from 0 to 1
and if sqrt(x^2+ y^2) < 1 , then we call it success , we can simulate this or many trials
c)
code in python
import numpy as np
import matplotlib.pyplot as pl
trials = 10000
counts = 0
for i in range(trials):
x =
np.random.random()
y =
np.random.random()
x2 =
x**2
y2 =
y**2
x_y = x2 +
y2
dxy =
np.sqrt(x_y)
if dxy <=
1:
counts = counts + 1
print ("number of trial =" ,trials ,",required probability is ::",counts/trials)