Search code examples
pythonrsimulationrandom-walk

How does one sample a random walk on a circle with a Gaussian step size in R or Python?


I am trying to obtain samples of a random walk on a circle that takes steps according to N(0, \sigma). To do this for a discrete random walk one calculates the cumulative sum of {+1,-1} coin tosses and then does mod the number of states on the circle at each step to obtain the current position. My question is: how to modify this for the continuous case?

Thanks in advance if anyone can help!


Solution

  • If the N(0,sigma) step distribution refers to the distribution of arc lengths around the circle, then

     cumsum(rnorm(n,0,sigma)) %% (2*pi)
    

    should give a sample of the steps on the circle (in radians), starting from zero.