0
$\begingroup$

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.

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

fig1

$\endgroup$
  • $\begingroup$ Oh right thanks, i got this now. $\endgroup$ – PaladinDanse Nov 14 '18 at 17:58
0
$\begingroup$

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

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.