如何生成具有 n 维的 RandomWalk?
我已经有一些 1 维或 2 维随机游走的例子,但现在我必须编写一个 n 维的随机游走,我真的不知道怎么做。
以下是 2 个维度的 2 个示例:
RandomWalk2DLattice[n_] :=
Accumulate[Through[{Cos, Sin}[# \[Pi]/2]] & /@ RandomInteger[3, {n}]]
rw = RandomWalk2DLattice[500];
Show[Graphics[{Line[rw], {PointSize[.02], Point[rw[[{-1}]]],
Point[{0, 0}]}}, Axes -> True], AspectRatio -> Automatic]
有人有答案吗?