I have following 2-dimensional random variable $(x,y)$: $$ f(x,y) = 1, \quad 0 \leq x \leq 1, \quad 0 < y \leq 1 $$
I have to find density function of random variable $Z = \frac{X}{Y}$.
I am trying to define another 2-D random variable: $$ Z = \frac{X}{Y} \\ W = Y $$
We can define a function: $$ g(x,y) = (\frac{x}{y}, y)\\ g^{-1}(z,w) = (zw, w) $$
Jacobian determinant is equal to $w$. Then, new density function $h$ should be equal to: $$ h(z,w) = f(zw, w) \cdot w = w $$
If we look at these variables, we see that $z \in [0;\infty]$ and $w \in [0,1]$.
However, if we try to find marginal density for variable $z$: $$ h_z(z) = \int_0^1 w \mathrm{d} w = \frac{1}{2} $$
But then, obiviously, if density function is equal to $\frac{1}{2}$ and $z \in [0;\infty]$, it can't be density function, because sum of probabilities doesn't sum to $1$.
Where have I made mistake?
The joint density of $(X,Y)$ is $$ f(x,y)=\mathbf{1}_{0<x<1}\mathbf{1}_{0<y<1} $$ and hence the density of $(X/Y,Y)$ is $$ h(z,w)=|w|f(zw,w)=w\mathbf{1}_{0<zw<1}\mathbf{1}_{0<w<1}=w\mathbf{1}_{0<z<w^{-1}}\mathbf{1}_{0<w<1}. $$ The marginal density of $X/Y$ is $$ h(z)=\int_\mathbb{R} h(z,w)\,\mathrm dw $$ which is zero for $z\leq 0$ and for $z>0$ equals $$ h(z)=\int_{\mathbb{R}}w\mathbf{1}_{0<w<z^{-1}}\mathbf{1}_{0<w<1}\,\mathrm dw=\int_0^{\min(1,z^{-1})}w\,\mathrm dw=\frac12 \min(1,z^{-2}). $$ Thus we conclude that $$ h(z)= \begin{cases} 0,\quad &z\leq 0,\\ \frac12, \quad &0<z<1,\\ \frac12 z^{-2},\quad &z\geq 1. \end{cases} $$