# Thread: Random Number Generation

1. ## Random Number Generation

So, the question is to describe a process, using the accept-reject algorithm, that generates values of x with the given distributions, assuming that we can only generate a uniform number

The one I'm stuck on is x~f(x) proportional to (1+(x^2)/5)^(-3) for 0 =< x =< 4
I took the derivative, set it equal to zero, but when I solved for x I found that it was the sqrt(-1/5), which I'm pretty sure is incorrect. Does anyone know how I could fix this? Plugging that value back into the original equation does indeed yield a number, but I'm fairly certain I shouldn't be using complex values...

Thanks!

2. Originally Posted by mistykz
So, the question is to describe a process, using the accept-reject algorithm, that generates values of x with the given distributions, assuming that we can only generate a uniform number

The one I'm stuck on is x~f(x) proportional to (1+(x^2)/5)^(-3) for 0 =< x =< 4
I took the derivative, set it equal to zero, but when I solved for x I found that it was the sqrt(-1/5), which I'm pretty sure is incorrect. Does anyone know how I could fix this? Plugging that value back into the original equation does indeed yield a number, but I'm fairly certain I shouldn't be using complex values...

Thanks!
You are required to use the acceptance-rejection sampling method. You do this by generating two uniform RV $\displaystyle x\sim U(0,4),~ y\sim U(0,\text{max}_{x \in [0,4]}(f(x))$. Then $\displaystyle x$ is accepted if $\displaystyle y<f(x)$ and rejected otherwise.

CB