Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In 1827, the botanist Robert Brown was studying pollen particles as they floated in water. When viewed through a microscope, he observed that the particles seemed to move around as if the were alive. Although he couldn’t have known at the time, the seemingly random motion was caused by the collision of water molecules against the pollen particle. Later on, the random motion he observed would be given the name ‘Brownian Motion’.

# Simulating Brownian Motion

We can model what Brown may have seen by simulating a two dimensional Brownian Motion. Executing the following code in R will produce a chart as if we had recorded the location of the pollen particle every minute (or some other arbitrary time interval) and connected the points in sequence.

n <- 100
y <- rep(0,n)
x <- rep(0,n)
for(i in 2:n){
y[i] <- y[i-1] + rnorm(1,0,1)
x[i] <- x[i-1] + rnorm(1,0,1)
}
plot(x,y, type="l", col="blue", ylim=c(-10,10), xlim=c(-10,10))