# 2d-RandomWalks with N steps and fixed distance between first and last point

community, I'm trying to figure out a way how to create a 2d list simulating a N-Step-Randomwalk with a fixed distance between first and last point. I already got the RandomWalk with the step size 1:

Input:

RW2D[n_] := Accumulate[Through[{Cos, Sin}[#]] & /@ RandomReal[{0, 2 [Pi]}, n]]

I have no idea how to connect the first and the last point. I'd be happy to receive some help. Thanks alot Greetings.

• Why not use standard features like RandomFunction[RandomWalkProcess[0.5], {0, 10^3}, 2]? – Alex Trounev Nov 14 '18 at 17:18
• I'm relatively new to this software so i find it easier to have the points in a list. – PaladinDanse Nov 14 '18 at 17:27
• Sorry, did not notice that you are walking in a circle. This is 1D and not 2D. – Alex Trounev Nov 14 '18 at 17:28
• But it turns out 2D. I fixed your typo RW2D[n_] := Accumulate[Through[{Cos, Sin}[#]] & /@ RandomReal[{0, 2*Pi}, n]]; ListLinePlot[RW2D] – Alex Trounev Nov 14 '18 at 17:37

## 2 Answers

RW2D[n_] :=
Accumulate[Through[{Cos, Sin}[#]] & /@ RandomReal[{0, 2*Pi}, n]]
Table[ListLinePlot[RW2D[n], PlotLabel -> Row[{"n=", n}]], {n, {10, 100, 1000}}] • Oh right thanks, i got this now. – PaladinDanse Nov 14 '18 at 17:58

This is a Graph method where you set the random walk start point, the end point, and the number of steps in between. It computes all possible paths and random pick one, therefore it makes sense only for small grids and number of steps 