search for: ydir

Displaying 1 result from an estimated 1 matches for "ydir".

Did you mean: dir
2010 Dec 02
4
2D Random walk
I've wrote some code to simulate a random walk in 2 dimensions on a lattice. Basically I want to add something in to make it plot it point by point so you can see what is going on. Heres my code for the random walk in 2d RW2D<-function(N) { i<-0 xdir<-0 ydir<-0 xpos<-vector() xpos[1]<-xdir ypos<-vector() ypos[1]<-ydir for (i in 1:N-1) { r<-runif(1) if(r<=0.25) {xdir<-xdir+1} if(r>0.25 && r<=0.5) {xdir<-xdir-1} if(r>0.5 && r<=0.75) {ydir<-ydir +1} if(r>0.75) {ydi...