Taiyun Wei

Brownian Motion

The function brownian.motion() has illustrated the phenomenon of Random Walk on the 2D plane. For a point (x, y), its next location is (x + rnorm(1), y + rnorm(1)).

R Code and Animation

library(animation)
ani.options(interval = 0.05, nmax = 100)
par(mar = c(3, 3, 1, 0.5), mgp = c(2, 0.5, 0), tcl = -0.3, bg = "white", cex.axis = 0.8, 
    cex.lab = 0.8, cex.main = 1)
brownian.motion(pch = 21, cex = 5, col = "red", bg = "yellow")