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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to