[R] generate combination multiset (set with repetition)
G. Jay Kerns
gkerns at ysu.edu
Fri Dec 12 00:48:18 CET 2008
Dear Reuben,
[snip]
> my questions now are... how would I generalize functions 3 and 4 for m
> And, which of the 4 functions would be best for varying ranges of
> n and m? I am expecting values for n to range between 1 and 1e3, while
> m will range between 1 and 1e6.
>
> Reuben
>
Regarding your 2nd question, for the values of n and m that you
request, the answer is "none". The number of combinations is
astronomically large. To get an idea, try
library(prob)
nsamp( n, m, ordered = FALSE, replace = TRUE )
for assorted values of n and m.
Bearing the above in mind, it may be useful to think carefully about
_why_ it is desired to have all possible combinations. In some
circumstances, it is good enough to randomly generate combinations and
draw inferences from a sampling distribution of some sort associated
with the problem.
Good luck.
Jay
***************************************************
G. Jay Kerns, Ph.D.
Associate Professor
Department of Mathematics & Statistics
Youngstown State University
Youngstown, OH 44555-0002 USA
Office: 1035 Cushwa Hall
Phone: (330) 941-3310 Office (voice mail)
-3302 Department
-3170 FAX
E-mail: gkerns at ysu.edu
http://www.cc.ysu.edu/~gjkerns/
More information about the R-help
mailing list