Wolfram Language

Open live version

Plot a Random Walk

Make a plot of a random walk. This example appears in Stephen Wolframs video Introduction to the Wolfram Language.


code

ListLinePlot[Accumulate[RandomReal[{-1, 1}, 1000]]]

how it works

RandomReal[{-1,1},1000] gives a list of 1000 random numbers uniformly distributed between -1 and 1, Accumulate gives the successive accumulated totals of the random numbers, and ListLinePlot plots the resulting list of values with a line.

ListLinePlot[Accumulate[RandomReal[{-1, 1}, 1000]]]