Distribution of $ \tan \theta$ when $\theta$ is uniform on $[0,2\pi)$ Suppose you have $X$ and $Y$, which are two random variables whose joint distribution is the standard Gaussian distribution. Let random variables $R \geq 0 $ and $\theta \in [0, 2 \pi)$ satisfy: $X=R\cos\theta$ and $Y=R\sin\theta$.
Let $Z=\frac{Y}{X}$.
Thus, to find the density of $Z$, I did:
$Z= \tan \theta$.
And so, $$F_Z(z)=P(Z\leq z) = P(\tan \theta \leq z) = P( \theta \leq \arctan z)$$
Since $ \theta\sim \text{Uniform} [0, 2\pi)$ due to the fact that $X$ and $Y$ are standard Gaussian and deducing the distribution of $\theta$ from the joint distribution of $ R$ and $ \theta $, we get that this is equal to:
$ \int_{0}^{\arctan z} \frac{1}{2} dt$, which then works out to be equal to $\frac{\arctan(z)}{2} $.
After differentiating this to obtain the density function of $Z$, I get:
$$ f_Z(z)= \frac{1}{2\pi(1+{z^2})}$$
I am not sure about what the limits of $Z$ or $\theta$ should now be.
Any feedback will be appreciated.
 A: Let's think about this for a bit.  First, we have to consider what values $Z = Y/X$ may take on for $(X,Y) \in \mathbb R^2$.  Suppose $X > 0$.  Then $Z = Y/X \propto Y$ and so $Z \in \mathbb R$.
Now when we perform the transformation $Z = \tan \theta$, and $\theta \in [0,2\pi)$, this induces some discontinuity because, for instance, $\theta = \pi/2$ leads to $Z$ being undefined, but then $\theta = \pi/2 + 0.01$ gives $Z < 0$.  So we need to be a bit more careful.  For this reason we cannot simply write $$\Pr[\tan \theta \le z] = \Pr[\theta \le \tan^{-1} z].$$  Concretely, if we set $z = 1$, then the inequality $\tan \theta \le 1$ on $\theta \in [0, 2\pi)$ leads to the set $$\theta \in [0, \pi/4] \cup (\pi/2, 5\pi/4] \cup (3\pi/2, 2\pi)$$ and consequently $$\Pr[\tan \theta \le 1] = \frac{3}{4}.$$  This example actually illustrates how we should compute the correct probability.

We can see from the graph of $\tan \theta$ on $[0,2\pi)$ that the desired probability is simply twice the length of the interval within the subset $\theta \in (\pi/2, 3\pi/2)$ that satisfies $\tan \theta \le z$; i.e., $$\Pr[\tan \theta \le z] = 2 \Pr[\pi/2 < \theta \le \pi + \tan^{-1} z]$$ where we take $\tan^{-1} z \in (-\pi/2, \pi/2)$.  This gives us $$F_Z(z) = 2 \frac{\pi + \tan^{-1} z - \pi/2}{2\pi} = \frac{1}{2} + \frac{\tan^{-1} z}{\pi}, \quad -\infty < z < \infty.$$  And now this CDF looks nice and monotone, and satisfies $F_Z(-\infty) = 0$ and $F_Z(\infty) = 1$ whereas yours did not.  The density is therefore $$f_Z(z) = \frac{1}{\pi(1+z^2)},$$ which integrates correctly to $1$ on $z \in (-\infty, \infty)$.  This is known as a Cauchy distribution.
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\on}[1]{\operatorname{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
Besides notation details, the answer is reduced to the evaluation of the following integral:
\begin{align}
&\bbox[5px,#ffd]{\int_{0}^{2\pi}{1 \over 2\pi}\,\delta\pars{z - \tan\pars{\theta}}\dd\theta} =
{1 \over 2\pi}\int_{-\pi}^{\pi}\delta\pars{z - \tan\pars{\theta}}\dd\theta
\\[5mm] = &\
{1 \over 2\pi}\int_{0}^{\pi}\bracks{\delta\pars{z - \tan\pars{\theta}} +
\delta\pars{z - \tan\pars{-\theta}}}\dd\theta
\\[5mm] = &\
{1 \over 2\pi}\int_{-\pi/2}^{\pi/2}\bracks{\delta\pars{z + \cot\pars{\theta}} +
\delta\pars{z - \cot\pars{\theta}}}\dd\theta
\\[5mm] = &\
{1 \over \pi}\int_{0}^{\pi/2}\bracks{\delta\pars{z + \cot\pars{\theta}} +
\delta\pars{z - \cot\pars{\theta}}}\dd\theta
\\[5mm] = &\
{1 \over \pi}\int_{0}^{\pi/2}\delta\pars{\verts{z} - \cot\pars{\theta}}\dd\theta =
{1 \over \pi}\int_{0}^{\pi/2}
{\delta\pars{\theta - \on{arccot}\pars{\verts{z}}} \over
\verts{-\bracks{-\csc^{2}\pars{\theta}}}}\dd\theta
\\[5mm] = &\
{1 \over \pi}\int_{0}^{\pi/2}
{\delta\pars{\theta - \on{arccot}\pars{\verts{z}}} \over
\cot^{2}\pars{\on{arccot}\pars{\verts{z}}} + 1}\dd\theta
\\[5mm] = &\
{1 \over \pi}\,{1 \over \verts{z}^{2} + 1} =
\bbx{{1 \over \pi}\,{1 \over z^{2} + 1}}\\ &
\end{align}
