Home /
Expert Answers /
Advanced Physics /
please-answer-with-python-code-thank-you-very-much-estimation-20-point-pa840

???????

Please answer with python code. thank you very much.

$?$ Estimation (20 points) Consider a disk $D$ of radius 1 inscribed within a square of perimeter 8 centered at the origin. Then the ratio of the area of the disk to that of the square is $?/4$. Let $f$ represent the uniform distribution om the square. Then for a sampe of points $(X_{i},Y_{i})f(x,y)$ for $i=1,…,n,?^=(4/n)i=1?n?1_{(X_{i},Y_{i})?D}$ is an estimator of $?$, where $1_{A}$ is 1 if $A$ is true, and 0 otherwise. Consider the following strategy for estimating $?$. We start with $(x_{(0)},y_{(0)})=(0,0)$. Thereafter, generate candidates as follows: First, generate both $?_{x}$ and $?_{y}$ follow Uniform $(?h,h)$. If $(x_{(i)}+?_{x},y_{(i)}+?_{y})$ falls outside the square, regenerate $?_{x}$ and $?_{y}$ until the steptaken remainins within the square. Let $(X_{i+1},Y_{i+1})=(x_{(i)}+?_{x},y_{(i)}+?_{y})$. Increment $t$. This generates a sample of points over the square. When $t=n$, stop and calculate $?^$ as given above. (a) Implement this method for $h=1$ and $n=20000$. Compute $?^$. What is the effect of increasing $n$ ? What is the effect of increasing and decreasing $h$ ? Please comment. (b) Explain why this method is flawed. Using the same method to generate candidates, develop the correct approach by referring to the Metropolis-Hastings ratio. Prove that your sampling appraoch has a stationary distribution that is uniform on the square. (c) Implement your approach from Part (b) and caluclate $?^$. Experiment again with $?$ and h. Comment on your result.

The value of ? is calculated u