Skip to main content
1 of 3
Vitaliy Kaurov
  • 73.4k
  • 9
  • 206
  • 365

I sketched this up very quickly - so all is subject to check.

2D random walk generally is simple:

walk = Accumulate[RandomReal[{-.1, .1}, {100, 2}]];
Graphics[Line[walk], Frame -> True]

enter image description here

Confinement to square region {{0,1},{0,1}} would simple in principle with Mod[walk,2] (periodic boundary conditions) but visualizing will be hard:

Graphics[Line[Mod[walk, 1]], Frame -> True]

enter image description here

So I think logical, for periodic boundary conditions, to place it on a torus ( with arbitrary radiuses ):

map[φ_, θ_] = CoordinateTransformData["Toroidal" -> "Cartesian", 
              "Mapping", {r, θ, φ}] /. {\[FormalA] -> 1, r -> 2 Log[2]}

enter image description here

walk = Accumulate[RandomReal[{-.1, .1}, {10^4, 2}]];
Graphics3D[{Opacity[.5], Line[map @@@ walk]}, SphericalRegion -> True]

enter image description here

Vitaliy Kaurov
  • 73.4k
  • 9
  • 206
  • 365