Hey, what is the probability density function of the following random variable $\theta$ : $\theta=tan^{1}\frac{Y_1Y_2}{X_1X_2}$ for $X_1X_2>0$ and $\theta=tan^{1}\frac{Y_1Y_2}{X_1X_2}+\pi$ for $X_1X_2<0$. $X_1,X_2,Y_1,Y_2$ are all uniformly distributed random variables in the range 0 to 1. I arrived to this question when I was trying to find out the pdf of the angle between two randomly positioned nodes $(X_1,Y_1)$ and $(Y_1,Y_2)$. So basically I've 2 questions:(1). $X_1X_2$ and $Y_1Y_2$ have triangular distribution between 1 to +1. But their ratio distribution is difficult to find because the denominator takes 0 value outside the range (1,+1). So, I attempted to approximate this triangular by a Gaussian of variance $\frac{1}{9}.$ Now, ratio distribution of 2 Gaussian is Cauchy and then by taking $tan^{1}$ of that I got a uniform density function $\frac{1}{\pi}$ between $\frac{\pi}{2}$ to $\frac{\pi}{2}$. Am I doing anything wrong in this? And, my 2nd ques (2). $tan^{1}\frac{Y}{X}$ takes values only between $\frac{\pi}{2}$ to $\frac{\pi}{2}$. So, for ve $X$, I was adding a $+\pi$(See the 2$^{nd}$ line in the question). How does that reflect in the final pdf? The final pdf that I've obtained is only between $\frac{\pi}{2}$ to $\frac{\pi}{2}$. Pls help.

$\begingroup$ I don't think you should approximate anything like this by a Gaussian. There is no CLT involved. $\endgroup$– Leonid PetrovMar 24, 2013 at 16:40

$\begingroup$ I'm definitely not using CLT. I'm approximating a triangular distribution by a Gaussian by adjusting its variance such that 99% of its mass lie in the (1,+1) range. How else do you suggest me to find the pdf of $tan^{1}\frac{Y_1Y_2}{X_1X_2}$? $\endgroup$– PrakashMar 24, 2013 at 18:10

$\begingroup$ Okay, you're not using CLT, but the criticism remains valid: "approximating" the triangular distribution by a Gaussian changes the problem more or less completely. $\endgroup$– Greg MartinMar 24, 2013 at 20:12
2 Answers
First, you should probably solve the problem first without the two cases and the $+\pi$; the symmetry of switching $(X_1,Y_1)$ with $(X_2,Y_2)$ will allow you to convert your answer to the simpler problem  some pdf $f(x)$ supported on $(\frac\pi2,\frac\pi2)$  to the answer you're really looking for  which will be $\frac12f(x) + \frac12f(x\pi)$.
Second, I recommend trying to find the probability density function $g(x)$ for $\frac YX$, given that $X$ and $Y$ are independent random variables both with the triangle distribution on $(1,1)$  this is a ratio distribution. Afterwards you can adjust your answer to accommodate the $\tan^{1}$ function: the resulting probability density function will be $g(\tan^{1} x)/(1+x^2)$.
The way I was calculating the pdf of $Z=\frac{Y}{X}$ where $X$ and $Y$ are independent r.v. with triangular distribution in the range $(1,1)$ is as follows :
\begin{align*} F_Z(z)=Pr(\frac{Y}{X}\leq z)=\displaystyle\int_{1}^1 Pr(Y\leq xz)f_X(x)dx=\displaystyle\int_{1}^1\int_{1}^{min(xz,1)}f_Y(y)f_X(x)dydx \end{align*} Now, I calculate $Pr(Y\leq xz)$ as follows :\\ $\underline{z>0}$: [ Pr(Y\leq xz) = \begin{cases} \displaystyle\int_{1}^{xz}(1+y)dy & \text{if } \frac{1}{z} < x < 0 \\ \displaystyle\int_{1}^0 (1+y)dy + \displaystyle\int_0^{xz} (1y)dy & \text{if } 0 < x < \frac{1}{z}\\ 1 & \frac{1}{z} < x < 1 \end{cases} ]
$\underline{z\leq 0}$: [ Pr(Y\leq xz) = \begin{cases} \displaystyle\int_{1}^{xz}(1+y)dy & \text{if } \frac{1}{z} \geq x \geq 0 \\ \displaystyle\int_{1}^0 (1+y)dy + \displaystyle\int_0^{xz} (1y)dy & \text{if } 0 > x \geq \frac{1}{z}\\ 1 & 1 \leq x \leq \frac{1}{z} \end{cases} ]
Thus, $Pr(Y\leq xz)$ becomes :\ [ Pr(Y\leq xz) = \begin{cases} xz+\frac{x^2z^2}{2}+\frac{1}{2} & \text{if } \frac{1}{z} \geq x \geq 0, z > 0 \ xz\frac{x^2z^2}{2}+\frac{1}{2} & \text{if } 0 < x < \frac{1}{z}, z > 0 \ 1 & \text{if } \frac{1}{z} < x < 1, z>0 \ xz+\frac{x^2z^2}{2}+\frac{1}{2} & \text{if } 0 \geq x \geq \frac{1}{z}, z < 0 \ xz\frac{x^2z^2}{2}+\frac{1}{2} & \text{if } \frac{1}{z} < x < 0, z < 0 \ 1 & \text{if } 1 < x < \frac{1}{z}, z<0 \
\end{cases} ]
Then, plugging in these values of $Pr(Y\leq xz)$ in the expression of $F_Z(z)$, I obtain :\ [ F_Z(z) = \begin{cases} \displaystyle\int_{min(1,\frac{1}{z})}^0(xz+\frac{x^2z^2}{2}+\frac{1}{2})(1+x)dx + \displaystyle\int_0^\frac{1}{z}(xz\frac{x^2z^2}{2}+\frac{1}{2})(1x)dx + \displaystyle\int_{\frac{1}{z}}^1 1.(1x)dx & \text{if } z>0 \\ \displaystyle\int_0^{\frac{1}{z}}(xz+\frac{x^2z^2}{2}+\frac{1}{2})(1+x)dx + \displaystyle\int_{\frac{1}{z}}^0(xz\frac{x^2z^2}{2}+\frac{1}{2})(1x)dx + \displaystyle\int_{1}^{\frac{1}{z}} 1.(1x)dx & \text{if } z \leq 0 \end{cases} ] So, now there are 3 cases for z: $0<z<1$, $1<z<\infty$ and $z\leq 0$\\ $\therefore$ Value of $F_Z(z)$ for each of these cases is as follows :\\ $\textbf{Case 1}$: $0<z<1$\ $\displaystyle\int_{\frac{1}{z}}^0(xz+\frac{x^2z^2}{2}+\frac{1}{2})(1+x)dx + \displaystyle\int_0^\frac{1}{z}(xz\frac{x^2z^2}{2}+\frac{1}{2})(1x)dx + \displaystyle\int_{\frac{1}{z}}^1 1.(1x)dx$\\ $\textbf{Case 2}$: $z>1$\ $\displaystyle\int_{1}^0(xz+\frac{x^2z^2}{2}+\frac{1}{2})(1+x)dx + \displaystyle\int_0^\frac{1}{z}(xz\frac{x^2z^2}{2}+\frac{1}{2})(1x)dx + \displaystyle\int_{\frac{1}{z}}^1 1.(1x)dx$\\ $\textbf{Case 3}$: $z\leq 0$\ $\displaystyle\int_0^{\frac{1}{z}}(xz+\frac{x^2z^2}{2}+\frac{1}{2})(1+x)dx + \displaystyle\int_{\frac{1}{z}}^0(xz\frac{x^2z^2}{2}+\frac{1}{2})(1x)dx + \displaystyle\int_{1}^{\frac{1}{z}} 1.(1x)dx$
I don't know where exactly I'm going wrong ! But I'm calculating this in the same line as the ratio of 2 uniform r.v. which is coming same as given in Wiki.