# Conditional distribution on the unit circle and a square

Let (X,Y) be uniformly distributed over $B=\{(x,y) \in \mathbb{R}^2: x^2+y^2 \leq 1 \}$ resp. $Q=[-1,1]^2$. Now I want to calculate the conditional distributions and of Y given X=x. And then the same for $R=\sqrt(X^2+Y^2)$ and $\varphi = arctan(Y/X)$ (conditional distributions of $\varphi$ given R=r).

At first I calculated the densities: For the unit circle I get: f(x,y) = $\begin{cases} 1/\pi~~~ if~ x^2+y^2 \leq 1\\ 0 ~~~~~~ else \end{cases}$. $f_Y(y) = \frac{2 \sqrt(1-y^2)}{\pi}$

$f_X(x)= \frac{2 \sqrt(1-x^2)}{\pi}$

For the square I get: $f(x,y)= \begin{cases} 1/4~~~if (x,y) \in Q\\ 0~~~~~~else \end{cases}$.

$f_Y(y)=f_X(x)=1/2$.

How do I get now the conditional distributions? And how do I get the conditional distributions of $\varphi$?

For the disc, $B$,

$$f_{X|Y}(x|y) = \dfrac{f_{X,Y}(x,y)}{f_Y(y)} = \dfrac{1/\pi}{2\sqrt{1-y^2}/\pi} = \dfrac{1}{2\sqrt{1-y^2}}\qquad\text{for |x|\leq \sqrt{1-y^2}, otherwise 0.}$$

Symmetrically,

$$f_{Y|X}(y|x) = \dfrac{1}{2\sqrt{1-x^2}}\qquad\text{for |y|\leq \sqrt{1-x^2}, otherwise 0.}$$

So both these conditional distributions are uniform, which is as we would expect.

For $R,\varphi,\;$ we can use the "change of variable" method. Since $R=\sqrt{X^2+Y^2}$ and $\varphi=\arctan{\left(Y/X\right)}$, we have

$$X = R\cos\varphi \\ Y = R\sin\varphi.$$

So our Jacobian is

$$J=\begin{vmatrix} \dfrac{\partial{x}}{\partial{r}} & \dfrac{\partial{y}}{\partial{r}} \\ \dfrac{\partial{x}}{\partial{\varphi}} & \dfrac{\partial{y}}{\partial{\varphi}} \\ \end{vmatrix} =\begin{vmatrix} \cos\varphi & \sin\varphi \\ -r\sin\varphi & r\cos\varphi \\ \end{vmatrix} = r(\cos^2 \varphi + \sin^2 \varphi ) = r.$$

$$f_{R,\varphi}(r,\varphi) = f_{X,Y}(x(r,\varphi),\;y(r,\varphi))\; |J| = \dfrac{r}{\pi}\qquad\text{for 0\leq r \leq 1 and 0\leq \varphi \leq 2\pi}$$

$$f_R(r) = \int_0^{2\pi}{\dfrac{r}{\pi}\;d\varphi} = \left[ \dfrac{r\varphi}{\pi} \right]_0^{2\pi} = 2r.$$

$$f_{\varphi}(\varphi) = \int_0^1{\dfrac{r}{\pi}\;dr} = \left[ \dfrac{r^2}{2\pi} \right]_0^1 = \dfrac{1}{2\pi}.$$

Note that $f_{R,\varphi}(r,\varphi) = f_R(r)f_{\varphi}(\varphi)$ so $R,\varphi$ are independent. Therefore, $f_{\varphi|R}(\varphi|r)=f_{\varphi}(\varphi)$ and $f_{R|\varphi}(r|\varphi) = f_{R}(r)$.

$$\\$$

For the square, $Q$, we use a similar method.

$$f_{X|Y}(x|y) = \dfrac{f_{X,Y}(x,y)}{f_Y(y)} = \dfrac{1/4}{1/2} = \dfrac{1}{2}\qquad\text{for |x|\leq 1, otherwise 0.}$$

Symmetrically,

$$f_{Y|X}(y|x) = \dfrac{1}{2}\qquad\text{for |y|\leq 1, otherwise 0.}$$

This means $X,Y$ are independent.

For $R,\varphi$, we have the same Jacobian, $J$, as above. However, the ranges of the r.v.'s are different and more difficult. Firstly, the joint distribution:

$$f_{R,\varphi}(r,\varphi) = f_{X,Y}(x(r,\varphi),\;y(r,\varphi))\; |J| = \dfrac{r}{4}\qquad\text{for 0\leq \varphi \leq 2\pi and} \\ 0\leq R \leq \begin{cases} \dfrac{1}{\cos{\varphi}}, & \text{if k\pi - \dfrac{\pi}{4}\leq \varphi\leq k\pi + \dfrac{\pi}{4},\quad k\in\mathbb{Z}} \\ \dfrac{1}{\sin{\varphi}}, & \text{if k\pi + \dfrac{\pi}{4}\leq \varphi\leq k\pi + \dfrac{3\pi}{4},\quad k\in\mathbb{Z}.} \\ \end{cases}$$

If $0\leq r\leq 1,\quad f_R(r) = \int_0^{2\pi}{\frac{r}{4}\;d\varphi} = \left[\dfrac{r\varphi}{4}\right]_0^{2\pi} = \dfrac{\pi r}{2}.$

If $1\leq r\leq \sqrt{2},\quad f_R(r) = 8\int_{\arccos{(1/r)}}^{\pi/4}{\frac{r}{4}\;d\varphi} = \left[2r\varphi\right]_{\arccos{(1/r)}}^{\pi/4} = \dfrac{\pi r}{2} - 2r\arccos{(1/r)}.$

If $0\leq r\leq 1$,

$$f_{\varphi|r}(\varphi,r) = \dfrac{f_{R,\varphi}(r,\varphi)}{f_R(r)} = \dfrac{r/4}{\pi r/2} = \dfrac{1}{2\pi}.$$

If $1\leq r\leq \sqrt{2}$,

$$f_{\varphi|r}(\varphi,r) = \dfrac{r/4}{\pi r/2 - 2r\arccos(1/r)} = \dfrac{1}{2\pi - 8\arccos(1/r)}.$$