# Simulate random data with a given probability density function

Let $(X, Y)$ be a random vector with density $f(x,y) = c I_A(x,y)$ where $A=\{(x,y): 0<x^2<y<1\}$. $I_A$ is a characteristic function.

I need to simulate random data with this pdf.

It is possible generate samples from this distribution using the PDF?

• "pdf" is a pretty standard abbreviation for "probability density function". – Ian Sep 20 '15 at 21:30
• Probability density function – albert Sep 20 '15 at 21:30
• $I_A$ presumably means the indicator function of $A$. – Ian Sep 20 '15 at 21:32

In the rejection approach, you draw from a distribution which is not the one that you want, and then you reject points in such a way as to get to the correct distribution. Here you can sample uniformly from the square $(0,1) \times (0,1)$ and then reject a point $(x,y)$ whenever $x^2 \geq y$. (This assumes your problem is confined to the square $(0,1) \times 0,1)$; everything goes through the same if it instead confined to the rectangle $(-1,1) \times (0,1)$.)
In principle, you can make a faster method than this by computing the marginal distribution of (say) $X$, sampling $X$ using this marginal distribution, and then sampling $Y$ as $U(X^2,1)$. (Here it may help to know how to sample from a distribution given a CDF: Generation of random variable from a complicated CDF may be helpful.)
But even in this simple example, it is hard to invert the marginal CDF of $X$. In this case it is $\frac{3}{2} (x-x^3/3)$, so there is an analytic solution, but it is rather complicated. It would probably be faster to use Newton's method to compute a numerical solution than it would be to compute the analytic solution. So having fallback methods like the rejection method is very useful.
• In the rejection approach, it might be necessary to replace $(0,1)\times(0,1)$ by $(-1,1)\times(0,1)$. In the "simpler and faster approach", uniformly sampling $x$ is a bad idea since the density of $x$ is not constant but proportional to $1-x^2$. – Did Sep 20 '15 at 21:43