Simulation in R to check graphically that marginal distributions are correct The distribution on $R^2$ with joint density $h$ with respect to the Lebesgue measure is:
$$h(x,y)=\frac{3}{2}y 1_{A}(x,y), \ \  A=\{(x,y) \in R^2|0<y, x^2+y^2<1\}.$$
Then I have found the marginal density $f_X(x)=\frac{3}{4}(1-x^2)$
And therefore we get that the conditional distribution of Y given X is:
$$f(Y|X)=\frac{h(x,y)}{F_X(x)}=-\frac{2y}{x^2-1}$$
Now I have to use these results to simulate outcomes from the distribution of
$(X, Y)$, and check graphically that the marginal distributions are correct. I want to do that in R. But I'm not sure how to do that. I think I have to draw random outcomes $y_i$ from the marginal distribution of $X$. Then for each $x_i$, I think I have to draw an outcome from $P_{x_i}$ (the conditional distribution
of Y given X). But how can I do that simulation? I think simulation from a continuous distribution with CDF $F$ can be generated as $F^{-1}(U)$ where $U$ is uniform on $(0,1).$ Is that a correct understanding? Can anyone help me how to do that simulation in R?

One possible approach for the requested graphical results:

*

*Start by simulating points in the rectangle with vertices $(0,0)$ and $(1,1)$ so that $X\sim\mathsf{UNIF}(0,1)$ and, independently,
$Y\sim\mathsf{Beta}(2,1).$


*Then throw away points not in $A.$


*Then plot histograms of the remaining $X$'s and $Y$'s, which will
be negatively correlated.
Simulation in R:
set.seed(1129)
y1 = rbeta(10^4, 2, 1)
x1 = runif(10^4)
A = (x1^2+y1^2 < 1)
x = x1[A]; y = y1[A]  # keep points in A

summary(x); length(x); sd(x)
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
0.0001593 0.1693985 0.3445088 0.3733047 0.5529737 0.9886407 
[1] 6579              # number of X's
[1] 0.2428481         # SD of X's
summary(y);  length(y);  sd(y)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
0.01055 0.41670 0.61122 0.59068 0.77998 0.99884 
[1] 6579
[1] 0.2326322
cor(x,y)
[1] -0.3749655        # Negative correlation


Code for figure:
par(mfrow=c(1,3))
 plot(x,y, pch=".")
 hist(x, prob=T, col="skyblue2")
 hist(y, prob=T, col="skyblue2")
par(mfrow=c(1,1))

Note: You will get better approximations for marginal means and
standard deviations, and for the correlation if you start with a million points. But then the scatterplot is to conjested
to read. So I used only $10\,000$ initial points, of which
$6579$ are in set $A.$
