I am trying to create a series of numbers to simulate a Levy Walk in R. I am currently using the following code:
alpha=2 n=1000 x=rep(0,n) y=rep(0,n) for (i in 2:n){ theta=runif(1)*2*pi f=runif(1)^(-1/alpha) x[i]=x[i-1]+f*cos(theta) y[i]=y[i-1]+f*sin(theta) }
The code works as expected, and I can generate numbers according to my requirements. The figure below shows such a βLevy Hallβ: 
The following histogram confirms that the numbers generated (i.e. f) actually belong to the power law:

My question is this: The resulting step lengths (i.e. F) are quite large. Can I change the code so that the step lengths fall only at some boundary [fmin, fmax]?
PS I intentionally did not vectorize the code.
source share