n <- 1000
t <- 100
bm <- c(0, cumsum(rnorm(n,0,sqrt(t/n))))
steps <- seq(0,t,length=n+1)
plot(steps,bm,type="l",xlab="Time",ylab="B(t)")
This is what I have managed to do but the steps do not make total sense.
- Why must we define n and t?
- Why do we separate the 0 from the cumsum?
- Why we use the function cumsum?
- What is the significance of (n,0,sqrt(t/n))?
- Why do we define steps?
How would this code be modified to simulate a two-dimensional Brownian motion path or several Brownian motions?