Simulate a random variable by the given density

118 Views Asked by At

Given is the density $$f(x)=\begin{cases} \frac{3}{4}\left(2x-x^2\right)&\mbox{if }x \in (0,2) \\ 0&\mbox{else}\end{cases}$$

Find a random variable for the density.

There are probably several methods for doing this but I only know of inverse transform and I like to try to use it here.

Firstly, we need the distribution function of the density. It is (just assume this is correct):

$$F(x)=\begin{cases} \frac{3}{4}x^2-\frac{1}{4}x^3&\mbox{if }0<x\leq 2 \\ 1 &\mbox{if }x>2\\ 0 &\mbox{if }x<0\end{cases}$$

Now we need to inverse this distribution function: $$y=\frac{3}{4}x^2-\frac{1}{4}x^3$$

I used a software for this one because it got very complicated when I tried to do it by hand :(

$$x= \sqrt[3]{2\sqrt{y^2-y}-2y+1}+\frac{1}{\sqrt[3]{2\sqrt{y^2-y}-2y+1}}$$

While the other party of the distribution function didn't need any change except for the cases, so for the inverse we have

$$F^{-1}(y)=\begin{cases} \sqrt[3]{2\sqrt{y^2-y}-2y+1}+\frac{1}{\sqrt[3]{2\sqrt{y^2-y}-2y+1}}&\mbox{if }\\ 1 &\mbox{if }\\ 0 &\mbox{if }\end{cases}$$

I didn't expect it will end up that complicated, I don't even know what cases I need to use and how the inverse of $0$ will be treated as it doesn't seem to be defined : /

Maybe there is an easier way of solving the problem or did I miss an important step / did a mistake somewhere? :s