brownian.motion {animation}R Documentation

Demonstration of Brownian motion on the 2D plane

Description

Demonstrate Brownian motion (random walk) in a 2D scatterplot.

Usage

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), ...)

Arguments

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

Details

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.

Value

None (invisible `NULL').

Author(s)

Yihui Xie

See Also

ani.start, ani.stop

Examples

# 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)

[Package animation version 0.2-0 Index]