Distribution of $ \tan \theta$ when $\theta$ is uniform on $[0,2\pi)$

density functionnormal distributionprobabilityprobability distributionsstatistics

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.

Best Answer

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.

enter image description here

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.

Related Question