# 2-dimensional random walk

b = RandomVariate[NormalDistribution[0, 1]];
ListlinePlot[b, PlotRange -> 35]


I am so new to Mathematica. I am trying to generate a 2-dimensional walk with variance =1 and plot this. However, I do not get its plot.

Can you help me? Thank you so much.

FoldList[Plus, {0, 0}, RandomVariate[NormalDistribution[0, 1], {500, 2}]] // Line // Graphics


Generate a list of random numbers and Accumulate:

b = Accumulate @ RandomVariate[NormalDistribution[0, 1], 500];

ListLinePlot[b, PlotRange -> 35]


For 2D, you can generate pairs of random numbers and Accumulate:

SeedRandom[1]

b2 = Accumulate @ RandomVariate[NormalDistribution[0, 1], {500, 2}];

ListLinePlot[b2, AspectRatio -> Automatic]


• Why do we need {500,2}? Thank you so much!
– Bora
Jan 26, 2021 at 1:03
• @Bora, RandomVariate[NormalDistribution[0, 1], {n, m}] generates an nXm matrix the entries of which are independent realizations of a random variable distributed NormalDistribution[0, 1].
– kglr
Jan 26, 2021 at 1:10
• One last question. Is there any way to start the random walk at the origin? I am really grateful for your help.
– Bora
Jan 26, 2021 at 1:49
• Prepend the list with {0,0} before accumulating: b2 = Accumulate @ Prepend[RandomVariate[NormalDistribution[0, 1], {500, 2}], {0,0}]
– kglr
Jan 26, 2021 at 2:15
• Assuming that the x and y axes are equivalent, it's probably worth using the AspectRatio -> Automatic option on ListLinePlot. Jan 26, 2021 at 18:57