first of all I have to say I'm a physicist and didn't have a single lecture on mathematical statistics or similar courses, so I'd like to apologize in advance for any inconvenience arising by notation.
My problem is basically of a very simple nature: Given a probability density $f(x,y)$ I have to find the probability density $p(z)$ of a variable $z(x,y)$.
Since my real problem is far too complicated to state here, let us for arguments sake assume that
\begin{align} f(x,y) = \frac{3}{8} \sin(x)^3 \sin(y) \qquad z(x,y) = x^2 + y^2 \qquad x,y \in [0,\pi] \end{align}
The first idea I had was a simple coordinate transformation \begin{align} \Phi : \begin{pmatrix}x \\ y\end{pmatrix} \longrightarrow \begin{pmatrix}z \\ y\end{pmatrix} \end{align} so that $p(z) = \int_Y f(x^{-1}(z),y) \left| \det J_{\Phi}\right| dy$. This doesn't seem to work at all...
My reasoning is this: Assuming $y=y_0=const.$ we can calculate $p(z,y_0) =f(x^{-1}(z),y_0) \left| \det J_{\Phi}\right| $, that is the distribution of $z$ along the line of $y_0$. Summing over all $y_0$ should then yield the distribution $p(z)$.
My second approach was more of a brute-force solution:
\begin{align} p(z_0) &= \int_X \int_Y f(x,y) \delta(z_0-z(x,y)) dxdy \\ &= \int_{z^{-1}(z_0)} \frac{f(x,y)}{\sqrt{\left|\nabla z(x,y)\right|}} d\sigma \\ &= \frac{3}{8}\int_{x^2 + y^2 = z_0} \frac{\sin(x)^3\sin(y)}{2 \sqrt{x^2+y^2}} dx dy \end{align}
Evaluating this line-integral numerically yields the correct result (I've written a simple Monte-Carlo simulation to compare my solutions). Unfortunately I don't see how to solve this kind of integrals analytically.
I would be very happy if someone could shine some light on this problem for me.
Thanks in advance :)
*Edit:
Solution to the integral approach: \begin{align} p(z_0) &= \frac{3}{16} \int_{x^2+y^2 = z} \frac{\sin(x)^3\sin(y)}{\sqrt{x^2+y^2}} dx dy \\ &= \frac{3}{16} \left( \int_0^{\frac{\pi}{2}} \sin(\sqrt{z} \cos(\varphi)^3 \sin(\sqrt{z} \sin(\varphi) H(\pi^2-z) \mathrm{d}\varphi \right. \\ &+\left. \int_{\arctan\left(\sqrt{\frac{z-\pi^2}{\pi^2}}\right)}^{\frac{\pi}{2}-\arctan\left(\sqrt{\frac{z-\pi^2}{\pi^2}}\right)} \sin(\sqrt{z} \cos(\varphi)^3 \sin(\sqrt{z} \sin(\varphi) \left(1-H(\pi^2-z)\right) \mathrm{d}\varphi \right) \end{align}
where $H$ is the Heaviside step function. A numerical integration yields (qualitatively) the correct distribution of z, see below for a comparison.
We have to distinguish between $0\le z \le \pi^2$ and $z \ge \pi^2$ since $x,y\in [0,\pi]$. If we'd take the full integral over $\varphi$ from $0$ to $\frac{\pi}{2}$ for all $z$ we would technically allow values for $x,y$ which are larger than $\pi$.
Our integration limits $\varphi_1 = \arctan\left(\sqrt{\frac{z-\pi^2}{\pi^2}}\right)$ and $\varphi_2 = \frac{\pi}{2} - \varphi_1$ ensure that $x,y\in[0,\pi]$ always. To see that, imagine a square $[0,\pi]^2$ and start drawing circles of radii $\sqrt{z}$ around the origin. For $\sqrt{z}>\pi$ only a portion of the circle is contained in the square. A straightforward calculation then reveals the limits on $\varphi$.
Numerical Integration : https://i.stack.imgur.com/2Ln2o.jpg
Monte-Carlo Distribution: https://i.stack.imgur.com/cRzH0.jpg