I am given a Rayleigh, distribution function:$$f(x)=\frac{1}{5}x\exp\left(\frac{-x^2}{10}\right)$$ with $x>0$ and asked to:
Use an appropriate random number generator algorithm to draw 500 samples from F(x).
What I thought on doing is using the Aceptance-rejection method :
Generate a rv $Y$ distributed as $G$.
Generate $U$ (independent from $Y$ ).
- If $U \leq \frac{f(Y)}{cg(Y)}$ , then set $X$ $=$ $Y$ (“accept”) ; otherwise go back to 1 (“reject”).
I thought that I will use the $\chi^2$ distribution as my $g(Y)$ with $k=1$ degrees of freedom. I made that decision on the fact that both functions have the same domain, namely $x\in(0,\infty)$ and their CDFs look "similar". Therefore : $$g(x)=\frac{x^{-\frac{1}{2}}\cdot\exp\left(-\frac{x}{2}\right)}{\sqrt{2}\Gamma\left(\frac{1}{2}\right)}$$ Then $$\frac{f(x)}{g(x)}=\frac{\sqrt{2}\Gamma\left(\frac{1}{2}\right)}{5}\cdot x ^{\frac{3}{2}}\cdot\exp\left(\frac{x}{2}-\frac{x^2}{10}\right)$$ And I found out that this function has a maximum at $$x=\frac{5+\sqrt{145}}{4}$$ which is around $4.26$. Hence $$\frac{f(x)}{g(x)}\leq c=4.26$$. But I also read that $c$ value has to be as "close" to 1 as possible and I think 4.26 is not "close" Is my calculation correct? Is it entirely wrong? Should I use different method for drawing that random samples? Thanks for any method