preserve neighborhood during random reordering

*To*: mathgroup at smc.vnet.net*Subject*: [mg45477] preserve neighborhood during random reordering*From*: Brent Pedersen <bpederse at nature.berkeley.edu>*Date*: Fri, 9 Jan 2004 05:20:47 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

I have an n*n Table. for example: t1 = Table[Random[Integer, {0, 10}], {k}, {k}]; I want to rearrange the elements in t1 randomly (my actual t1 has real data) such that for each entry t1[[i,j]] a random neighbor t1[[i+m,i+n]] is chosen to replace it. Once that neighbor is chosen, it can still be used to replace any of its other neighbors. In the reshuffling an entry can replace itself. Currently I have the size of the neighborhood fixed at 9 cells (-1<= m,n <= 1) but eventually, I need to extend it to 25 (-2 <= m, n <= 2), 49, etc. I can't get my mind around how to accomplish this in a straightforward manner. I've tried ListCorrelate[] and RotateRight[] and combinations of the two. Any suggestions would be appreciated. Thanks, -brent