Construct a random variable on the basis of another one that satisfies certain properties I'm trying to do an exercise from DeGroot's Probability and Statictics book, and I find it quite intriguing. Could you please give me some idea?
Here's the problem: suppose that X has the uniform distribution on the interval [0, 1]. Construct a random variable Y = r(X) for which the probability density function will be
$$ g(y)=\left\{
\begin{aligned}
\frac{3}{8}y^2\ \ \ \ \ for\ 0 < y < 2, \\
\\
0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ otherwise.
\end{aligned}
\right.
$$
The solution sais that $Y = 2X^{1/3}$, I agree with this answer, but I think that $Y = 2 - 2X^{1/3}$ satisfies the properties, too.
Could someone please tell me if there are two answers to this problem?
Thank you very much!
 A: $P(2-2X^{1/3} \leq y)=P(X \geq (1-\frac y 2 )^{3})=1-(1-\frac y 2 )^{3}$ and the density is $\frac 3 2(1-\frac y  2)^{2}=\frac 3 8 (2-y)^{2}$ which is not equal to the  given density function.
A: Quantile method of random sampling.
This important problem illustrates the use of the quantile function (inverse CDF) to transform $X \sim\mathsf{Unif}(0,1)$ to a desired distribution. [See also, noted as Related in the margin of this page.]
Here we use this method to generate and plot a million
realizations of $Y.$ [R code: Formal argument for curve must be x.]
set.seed(531)
x = runif(10^6)
y = 2*x^(1/3)
hist(y, prob=T, col="skyblue2")
 curve((3/8)*x^2, 0, 2, add=T, col="red", lwd=2)


Note: This method is important because pseudo-random
number generators typically generate values from
$\mathsf{Unif}(0,1)$
For example, if you need to sample $n = 5000$
values from $\mathsf{Gamma}(5, .1)$ you could
do it as follows:
set.seed(2021)
x = qgamma(runif(5000), 5, .1)
hdr = "n = 500: GAMMA(5, .1)"
hist(x, prob=T, br=30, col="wheat", main=hdr)
 curve(dgamma(x, 5, .1), add=T, col="blue", lwd=2)


It happens that R has a procedure rgamma to take random samples form a gamma distribution. In any one statistical software program, not
all useful probability distributions can have their
own random procedures. But often you can use the
quantile method to do it yourself.
