# Cosine of a triangular random variate

Good morning,

I want to calculate the probability density function of a random variate $Z=cos(Y)$, where $Y=Φ_1−Φ_2$ and $Φ_{1,2}∼U(0,2π)$, that is both variables are uniformly distributed in $(0,2π)$ and also independent. This last hypothesis makes $Y$ a triangular distribution in $(−2π,2π)$, so with this pdf: $$f_Y(y)=\frac{1}{2π}\biggl( 1−\frac{|y|}{2π} \biggr )$$

I calculate Z using the funtamental theorem. When $−2π<y<2π$ we have 4 solution to the equation $z=cos(y)$: \begin{align} f_Z(z) & =∑f_Y(\cos^{−1}(z)) \biggl |\frac{1}{−\sin(\cos^{−1}(z))} \biggr | =4⋅\frac{\frac{1}{2π}(1−\frac{|\cos^{−1}(z)|}{2π})}{\sqrt{1-z^2}} \\ &=\frac{2\biggl (1−\frac{\cos^{−1}(z)}{2π}\biggr)}{π \sqrt{1 - z^2}}, \ \ \ \ \ \ −2π<\cos^{−1}(z)<2π \end{align}

I have now two problems:

1. it's not verified the property of normalisation of $f_Z(z)$;

2. if I calculate the cumulative distribution function by integrating the pdf from $-1$ to $\infty$ $$F_Z(z)=\frac{\cos^{−1}(z)(\cos^{−1}(z)−4π)}{2π^2}+3/2$$ and compare this CDF with the ECDF estimated with Matlab, the comparison is not good, it's like something's missing.

Somebody can tell me where's the mistake?

Stephen

I think I solved the problem, perhaps someone else could be interested in the result. My mistake was that there are 4 different $y$ that verify the equation $z = \cos(y)$, while I first considered the same solution (bad error).
With this result, the $f_Z(z)$ seems to become a little difficult to analyse, but, for the joy of all the engineers who are reading, there's no need to analyse it, because you can easily verify with Matlab that ... (suspense) ... the random variate $Z$ is distributed as an Arcsin variable!
Theorem 1: Given two random variables uniformly distributed and independent, $\Phi_1 \sim \mathcal{U}(0, 2\pi)$ and $\Phi_2 \sim \mathcal{U}(0, 2\pi)$, then the random variate $Z$ given by the transformation $Z = \cos(\Phi_1 - \Phi_2)$ has an arcsine probability distribution in $(-1, 1)$ (arcsinely distributed in $(-1, 1)$?) , with these probability density function and cumulative distribution function: $$f_Z(z) = \frac{1}{\pi \sqrt{1-z^2}} \qquad \qquad F_Z(z) = \frac{2}{\pi} \arcsin\biggl(\sqrt{\frac{z+1}{2}}\biggr) \\$$ $\square$
Who wants to find out an analytical demonstration for this theorem, is welcomed. Anyway, if you generate with Matlab two independent random variates uniformly distributed in $(0, 2\pi)$, then calculate $Z = \cos(\Phi_1 - \Phi_2)$ and its empirical cdf with the command ecdf, if you compare what you get with the CDF shown in the theorem, you'll find out they're the same:)