Suppose we want to simulate a point located at random in a circle of radius
\(r\) centered at the origin. That is, we want to simulate \(X, Y\) having joint
density
$$
f(x, y)=\frac{1}{\pi r^{2}}, \quad x^{2}+y^{2} \leqslant r^{2}
$$
(a) Let \(R=\sqrt{X^{2}+Y^{2}}, \theta=\tan ^{-1} Y / X\) denote the polar
coordinates. Compute the joint density of \(R, \theta\) and use this to give a
simulation method. Another method for simulating \(X, Y\) is as follows:
Step 1: Generate independent random numbers \(U_{1}, U_{2}\) and set \(Z_{1}=\) \(2
r U_{1}-r, Z_{2}=2 r U_{2}-r\). Then \(Z_{1}, Z_{2}\) is uniform in the square
whose sides are of length \(2 r\) and which encloses, the circle of radius \(r\)
(see Figure 11.6). Step 2: If \(\left(Z_{1}, Z_{2}\right)\) lies in the circle
of radius \(r\) -that is, if \(Z_{1}^{2}+Z_{2}^{2} \leqslant r^{2}-\) set \((X,
Y)=\left(Z_{1}, Z_{2}\right) .\) Otherwise return to step \(1 .\)
(b) Prove that this method works, and compute the distribution of the number
of random numbers it requires.