[R] pivot algorithm

sethlatimer sethlatimer at comcast.net
Tue Nov 28 01:56:05 CET 2006


I am trying to simulate a self avoiding random walk in 2d of length 100. So I
am using two vectors of length 100 to encode the x and y coordinates.  At
each step I want apply a orthogonal transformation at a random point and
then check to see if the walk intersects with itself. This amounts to simply
checking to see if any of the ordered pairs of (x,y) coordinates in 1:j are
repeated in j+1:100. This seems like it should be really easy. But I cannot
find a simple method.

I have been calling the pivoted portion of the walk (xn[],yn[])



for(i in  1:j) for(m in {j+1}:100) if(xn[m]==x[i])  if(yn[m]==y[i])
dont_transform=1 else dont_transform=0
if(dont_transform==0) for(g in j:100) {x[g]=xn[g] ; y[g]=yn[g]}
z=c(x,y)
dim(z)=c(100,2)
z
 
maybe the right solution would be to use intersection() but I couldnt figure
out how to make it work.
Any advice would be appreciated.

Thanks 
Seth Latimer
-- 
View this message in context: http://www.nabble.com/pivot-algorithm-tf2715472.html#a7571334
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list