Some remarks about the limitations of simulations

There are various issues with running simulations including:

Recall that in the case of two-dimensional simple random walk on the lattice \(\mathbb{Z}^2\), the walker starts at the origin, then with equal probabilites chooses one of four directions, at each step, independently of the past. It is a theorem of Polya that the random walker will eventually return to the origin with probability \(1\). However, expected return time, like in one-dimension is infinite.

Below is some code which simulate a random walk in two-dimensions and waits for it to return to the origin, but we give up if it has wandered off too far. We find the probability of giving up, is nonzero even with a large cut-off.

step <-function(x){
y = sample(4,1, replace = TRUE)
if (y==1) {x<-x + c(0,1)}
if (y==2) {x<-x + c(1,0)}
if (y==3) {x<-x + c(0,-1)}
if (y==4) {x<-x + c(-1,0)}
x}

walk<-function(){
x = c(0,0)
x<-step(x)
n=1
while(sum(x^2) >0 & sum(x^2)< 10000){
  x<-step(x)
  n<- n+1
  n
}
x
}
process<-function(x){
  y =0
if (sum(x^2) >0){ y <- y+1}
y
  }

z = replicate(100, process(walk()))
mean(z)
## [1] 0.29

Note that in three dimensions, in the walker will eventually return with only about \(1/3\) of time.


Version: 4 October 2020