On Thu, Jan 26, 2012 at 08:29:22AM -0800, yan wrote: > what if I don't need to store the combination results, I just want to get the > combination result for a given row. > e.g. for the 5 elements divided into 3 groups , and if I give another > parameter which is the row number of the results, in petr's example, say if > I set row number to 1, then I get 1,2,3,1,1. > > So I need a systematic way of generating the combination, but I don't need > all the combinations in one go. > > Many thanks!!!!
Hi. I suppose that your question is meant for some larger example than 5 elements into 3 groups, since for this small case, we can store the whole table. Considering, for example, 200 elements and 3 groups, which you mentioned previously, this can probably be done using some implementation of large integers. The reason is that the final table has approximately 3^200/6 rows. So, the index of the last row has approx log2(3^200/6) = 314.4 bits. The standard numbers have 53 bits. For large integers, one can use packages "gmp", "Rmpfr" or some package for symbolic algebra, for example "Ryacas". Do you want to use a large integer m for a search of the exactly m-th partitioning in lexicographic order? Let me point out that sampling random partitionings can be done much easier. Petr. ______________________________________________ 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.