Re: [R] generate combination multiset (set with repetition)

2008-12-11 Thread Reuben Cummings
Thanks!!! works perfectly. I'll use t(rmultinom(x, m, rep(1,n))/m) for now and look up in my stats book the formula for determining the number of sample sizes to achieve a given p level. The second question was more pertaining to how many combinations are too many to attempt to calculate every poss

Re: [R] generate combination multiset (set with repetition)

2008-12-11 Thread Reuben Cummings
Good point, I actually thought about doing some kind of sampling before, but now I think I don't have a choice. Essentially, what I am doing is calculating possible asset allocation possibilities, e.g. N is the number of available assets and M is the available buckets of money to spend on the asse

Re: [R] generate combination multiset (set with repetition)

2008-12-11 Thread G. Jay Kerns
Reuben, On Thu, Dec 11, 2008 at 9:28 PM, Reuben Cummings wrote: > Good point, I actually thought about doing some kind of sampling > before, but now I think I don't have a choice. Essentially, what I am > doing is calculating possible asset allocation possibilities, e.g. > > N is the number of av

Re: [R] generate combination multiset (set with repetition)

2008-12-11 Thread G. Jay Kerns
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

Re: [R] generate combination multiset (set with repetition)

2008-12-11 Thread Reuben Cummings
Thanks for the suggestions!! I upgraded R which solved a few of my problems and got the following functions to work: # works for m > 2 # requires {prob] multisets1 <- function(n, m) { as.matrix(urnsamples(1:n, size = m, ordered = FALSE, replace = TRUE)) } # works for m > 2 # requires {mu

Re: [R] generate combination multiset (set with repetition)

2008-12-11 Thread Charles C. Berry
On Thu, 11 Dec 2008, Reuben Cummings wrote: Hi, This has been asked before but not sufficiently answered from what I could find. How do you create combinations with repetitions (multisets) in R? If I have set <- array(1:3) Why wrap 1:3 in array() ?? And I want to choose all combinations

Re: [R] generate combination multiset (set with repetition)

2008-12-11 Thread G. Jay Kerns
Dear Reuben, On Thu, Dec 11, 2008 at 12:53 PM, baptiste auguie wrote: > Hi, > > Perhaps you can use expand.grid and then remove the mirror combinations, > >> values <- 1:3 >> tmp <- expand.grid(values, values) >> unique.combs <- tmp[tmp[, 1]<=tmp[, 2], ] >> unique.combs[do.call(order, unique.com

Re: [R] generate combination multiset (set with repetition)

2008-12-11 Thread baptiste auguie
Hi, Perhaps you can use expand.grid and then remove the mirror combinations, values <- 1:3 tmp <- expand.grid(values, values) unique.combs <- tmp[tmp[, 1]<=tmp[, 2], ] unique.combs[do.call(order, unique.combs), ] # reorder if you wish Var1 Var2 111 412 713 522

[R] generate combination multiset (set with repetition)

2008-12-11 Thread Reuben Cummings
Hi, This has been asked before but not sufficiently answered from what I could find. How do you create combinations with repetitions (multisets) in R? If I have > set <- array(1:3) And I want to choose all combinations of picking 2 numbers, I want to get a print out like [,1] [,2] [1,]