[R] Permutation of a sequence to without changing local distribution

thmsfuller066 at gmail.com thmsfuller066 at gmail.com
Sun Aug 1 06:22:55 CEST 2010


Hello All,

Suppose that I have a sequence of letters (e.g., A..Z). I want to
permute the sequence to generate random sequences, such that the local
density of any letter with a window (say of length L) doesn't change
much before and after permutation.

One way that I can thing of is to require that the position of any
letter in the original sequence and the position of the same letter in
the new sequence should be smaller than L.

Suppose that v is the original sequence of letters. The following R
code random generates the sequence but without the distance constraint
as mentioned above.

sample(v, length(v))

To generate a random sequence, an intuitive idea is to break the
sequence into chunks of length L, then permute freely within each
chunk. The chunks are then slided 1 letter each time (until L-1 times)
and more sequence are generated.

My method may be crude. I'm wondering if there is a well established
method to generate a sequence satisfying the same local distribution.

-- 
Tom



More information about the R-help mailing list