brownian.motion {animation} | R Documentation |
Demonstrate Brownian motion (random walk) in a 2D scatterplot.
brownian.motion(n = 10, main = "Demonstration of Brownian Motion", xlim = c(-20, 20), ylim = c(-20, 20), pch = 21, cex = 5, col = "red", bg = "yellow", control = ani.control(nmax = 100, interval = 0.05), ...)
n |
Number of points in the scatterplot |
main, xlim, ylim, pch, cex, col, bg |
Arguments passed to plot.default to control the apperance of the scatterplot (title, points, etc), see points for details. |
control |
control parameters for the animation; see ani.control |
... |
other arguments passed to ani.control |
Brownian motion, or random walk, can be regarded as the trace of some cumulative normal random numbers: the location of the next step is just ``current location + random Gaussian numbers'', i.e.,
x[k + 1] = x[k] + rnorm(1)
y[k + 1] = y[k] + rnorm(1)
where (x, y) stands for the location of a point.
None (invisible `NULL
').
Yihui Xie
# show an animation in (Windows/X Window...) a graphics device # unless you have opened an invisible device like png(), pdf(), ... brownian.motion(n = 15, nmax = 150) ## Not run: # create HTML animation page ani.start() brownian.motion(n = 15, nmax = 100, saveANI = TRUE, width = 500, height = 500) ani.stop() ## End(Not run)