# How to generate random samples from a ratio distribution?

I have two i.i.d. random variables $X$ and $Y$ and I want to generate a set of $n$ random samples from the distribution of the ratio between the two variables $Z=X/Y$.

The pdf of $Z$ is described by: $$f_Z(t) = \int_{-\infty}^\infty |u| ~ f_{X,Y}(tu,u)~\mathrm{d} u,$$ and then its cdf: $$F_Z(t) = \int_{-\infty}^t f_Z(u)~\mathrm{d} u.$$ Then, in theory I can generate random samples $z\sim Z$ by: $$z=F^{-1}_Z(r),$$ where $r$ is a uniform random sample in $[0,1]$.

The problem is that obtaining $f_Z(t)$ is not straightforward, specially when $X$ and $Y$ are both Weibull distributions; neither it is to obtain $F_Z(t)$. Is there any way to obtain random samples from $Z$ by directly using random samples from the marginal distributions of $X$ and $Y$ ?

-
I presume by "random samples from $X$ and $Y$" you mean separate random samples from their marginal distributions? If you mean samples of $X$ and $Y$ together from the joint distribution, you just have to divide them to obtain random samples from $Z$. –  joriki Apr 11 '12 at 9:18
No, I meant samples from the marginal distributions of $X$ and $Y$. Actually $X$ and $Y$ are identical and independent variables. –  Lluis Apr 11 '12 at 9:54

The question as clarified in a comment is trivial. Since $X$ and $Y$ are independent, samples from their marginal distributions can be combined to produce a sample from their joint distribution, and the quotient is a sample from $Z$.