Re: [R] 2d rndom walk

2011-06-29 Thread Komal
walk.2d<-function(n) { rw <- matrix(0, ncol = 2, nrow = n) # generate the indices to set the deltas indx <- cbind(seq(n), sample(c(1, 2), n, TRUE)) # now set the values rw[indx] <- sample(c(-1, 1), n, TRUE) # cumsum the columns rw[,1] <- cumsum(rw[, 1]) rw[,2] <- cumsum(rw[, 2]) return

Re: [R] 2D Random walk

2011-06-29 Thread Komal
HI Jholtman, walk.2d<-function(n) { rw <- matrix(0, ncol = 2, nrow = n) # generate the indices to set the deltas indx <- cbind(seq(n), sample(c(1, 2), n, TRUE)) # now set the values rw[indx] <- sample(c(-1, 1), n, TRUE) # cumsum the columns rw[,1] <- cumsum(rw[, 1]) rw[,2] <- cumsum(rw[,

Re: [R] 2D Random walk

2011-06-29 Thread Komal
Please change the code to a user defined function. -- View this message in context: http://r.789695.n4.nabble.com/2D-Random-walk-tp3069557p3632734.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https:

[R] 2d rndom walk

2011-06-29 Thread Komal
Hi all, Can anyone please tell me how to calculate the expected distance covered in a 2d random walk. Please! -- View this message in context: http://r.789695.n4.nabble.com/2d-rndom-walk-tp3632468p3632468.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] 2D Random walk

2011-06-29 Thread Komal
Hi, I saw your code and try running it, it works!! Can you please write this code in a user defined function. I tried making it with making a function and cant run it. -- View this message in context: http://r.789695.n4.nabble.com/2D-Random-walk-tp3069557p3632459.html Sent from the R help maili