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
tlum...@u.washington.edu        University of Washington, Seattle
______________________________________________
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