[R] Constrained vector permutation
Thomas Lumley
tlumley at u.washington.edu
Fri Jan 29 00:04:30 CET 2010
On Thu, 28 Jan 2010, Jason Smith wrote:
>> It wouldn't be guaranteed to produce any usable permutation, but it seems
>> like it would be much faster and so could be repeated until an acceptable
>> vector is found. What do you think?
>>
>> Thanks--
>> Andy
>>
>
> I think I am not understanding what your ultimate goal is so I'm not
> sure I can give you appropriate advice. Are you looking for a single
> valid permutation or all of them?
>
> Since that constraint sets a ceiling on each subsequent value, it
> seems like you could solve this problem more easily and quickly by
> using a search strategy instead of random sampling or generating all
> permutations then testing. The constraint will help prune the search
> space so you only generate valid permutations. Once you are examining
> a particular element you can determine which of the additional
> elements would be valid, so only consider those.
It's easy to generate valid permutations this way. It does not appear straightforward to ensure that all valid permutations are sampled with equal probability, which I thought was part of the specification of the problem.
-thomas
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help
mailing list