# PDF or CDF of $D = \sqrt{1 - X^2 \sin^2{\theta}} - X \cos{\theta}$

How to calculate the PDF or the CDF of $D$ where:

$$D = \sqrt{1 - X^2 \sin^2{\theta}} - X \cos{\theta}$$

If $X$ is uniform distributed on $[-1, 1]$, $\theta$ is uniformly distributed on $[0, 2 \pi]$ and they are independent.

I know that: $$F_D(d) = \iint\limits_D \, f_\theta(\theta) f_X(x) \mathrm{d}x\,\mathrm{d}\theta$$

But I don't know how to find the ranges I should integrate on!

-
Do you mean $\{-1,1\}$, i.e., the atoms $-1$ and $+1$ or do you mean $[-1,1]$, i.e., the interval of real numbers $-1 \leq x \leq 1$? Same question for $\{0,2\pi\}$. – cardinal May 29 '11 at 15:31
Yes I mean on the interval of real number $-1≤x≤1$ – Osama Gamal May 29 '11 at 15:54

For $F_D(d)$ you need to integrate over the region of the $(x,\theta)$ plane where $-1 \le x \le 1$, $0 \le \theta \le 2 \pi$, and $\sqrt{1-x^2 \sin^2 \theta} - x \cos \theta \le d$. Here, for example (in red) is the region for $d = 1/2$:

And here is $d = 1$:

-
Yeah I know .. But how to find that ranges in numbers/equations to integrate!! – Osama Gamal May 29 '11 at 17:51
For example, if $0 \le d < 1/2$ it looks like there are three regions, one including $(x,\theta) = (-1,\pi)$, one in\cluding $(1,0)$ and one including $(1,2\pi)$. The curved part of the boundary has $\sqrt{1-x^2 \sin^2 \theta} - x \cos \theta = d$. Add $x \cos\theta$ to both sides, square and simplify, and you get $x^2 + 2 d x \cos \theta = 1 - d^2$, or $x = -d \cos \theta \pm \sqrt{1 - d^2 \sin^2 \theta}$. The version with $-$ is $-1$ when $\cos \theta = d/2$. (continued in next comment) – Robert Israel May 29 '11 at 18:10
So it looks like the bounds for the region including $(-1,\pi)$ are $\arccos(d/2) \le \theta \le 2 \pi - \arccos(d/2)$, $-1 \le x \le -d \cos \theta - \sqrt{1 - d^2 \sin^2 \theta}$. By symmetry ($x \to -x$, $\theta \to \theta \pm \pi$) this piece will give you half the area. – Robert Israel May 29 '11 at 18:17

The change of variables $z=\sqrt{1-x^2\sin^2\theta}-x\cos\theta$ and $u=\sqrt{1-x^2\sin^2\theta}$ indicates that the probability density function of $D$ is $$f_D(z)=\int \frac{u\mathrm{d}u}{\sqrt{1-u^2}\sqrt{1-2zu+z^2}}.$$ This integral might be transformed into an elliptic integral of the first kind but I did not check carefully enough the bounds on $z$ this change of variables involves to conclude.

To the OP: what did you try? And what makes you think the result can be expressed using only usual functions?

-
Sorry, What is OP? – Osama Gamal May 29 '11 at 22:29
You... :-)   – Did May 30 '11 at 5:03
Ah lol .. I was trying to find the PDFs of the random variables $u = \sqrt{1 - x^2 \sin^2{\theta}}$ and $v = x \cos{\theta}$ .. But I thought that I can't then calculate the joint PDF of $u$ and $v$ since they will be dependent. – Osama Gamal May 30 '11 at 7:50
Right. Did you manage to arrive at the expression of $f_D$ written in my post? – Did May 30 '11 at 11:25
No, I don't get it actually – Osama Gamal May 30 '11 at 17:13

If you are not interested in a particularly elegant expression, then you can very easily and simply calculate the CDF of $D$ as follows: $${\rm P}(D \le s) = \frac{1}{{4\pi }}\int_{[ - 1,1] \times [0,2\pi ]} {\mathbf{1}\big(\sqrt {1 - x^2 \sin ^2 \theta } - x\cos \theta \le s\big)\,dx d\theta } ,\;\; 0 \leq s \leq 2,$$ where $\mathbf{1}$ denotes the indicator function. Note that $D$ is supported on the set $[0,2]$ (hence the restriction $0 \leq s \leq 2$ above). Indeed, on the one hand, $D \geq 0$ since $$\sqrt {1 - x^2 \sin ^2 \theta } \ge x\cos \theta$$ for any $x \in [-1,1]$ and $\theta \in [0,2\pi]$ (this is trivial if $x\cos\theta \leq 0$; otherwise take squares on both sides), and, on the other hand, $D \leq 2$ since $$\sqrt {1 - x^2 \sin ^2 \theta } - x\cos \theta \le 1 + 1 = 2$$ (for $x$ and $\theta$ as above). Further note that the choices $(x,\theta)=(1,0)$ and $(x,\theta)=(-1,0)$ correspond to $D=0$ and $D=2$, respectively.

Finally, it should be noted that the double integral above can be calculated very quickly and accurately. For example, it took about a second to obtain the approximation $${\rm P}(D \leq 1) \approx 0.5813759999978363,$$ indicating that ${\rm P}(D \leq 1) = 0.581376$, whereas Monte Carlo simulations ($10^7$ repetitions) yielded a much less accurate approximation $${\rm P}(D \leq 1) \approx 0.5813805,$$ in about $40$ seconds.

-
Well, I guess it won't work for me since I'll use the PDF later in another work and it should be function of something – Osama Gamal May 30 '11 at 7:53