I have a problem that I have a hard time figuring out. We have a sequence of 10 numbers, 0 to 9. We want to find all the combinations where, when choosing from the sequence 18 times with replacement, we will have 4 of them repeated 3 times each, and the rest appearing once only.

Here is what my thought process is:

  • Choosing 4 numbers out of 10: $10\choose4$
  • Each repeating 3 times: $(\frac{1}{10})^3$
  • Unique sequences of the remaining 6 numbers: $\frac{6!}{10^6}$
  • Combination of all the unique sequences: ${10\choose 6}$

Thus combining them I will have: $10\choose4$$(\frac{1}{10})^3$$\frac{6!}{10^6}$${10\choose 6}$

Could someone please tell me if this is correct? and if not where did I go wrong.

  • $\begingroup$ Is this a question from a course or textbook? If so, please add the [self-study] tag & read its wiki. $\endgroup$ – Silverfish May 10 '16 at 20:36
  • 1
    $\begingroup$ Your question says "we want to find all the combinations" but you seem to be calculating some probability. Those are not the same thing. $\endgroup$ – Glen_b May 11 '16 at 2:38
  • $\begingroup$ @Glen_b I was very hesitant to work on this question, because of what you mention. Even after I was drawn to work through it, I couldn't believe that I wasn't missing out on something. But it seems like the simulation does approximate the simple combinations. $\endgroup$ – Antoni Parellada May 11 '16 at 3:58
  • $\begingroup$ It is unclear what you are asking, because "combination" usually means without regard to sequence, yet you include a consideration of unique sequences in your attempted answer. Could you perhaps give a few examples of distinct "combinations"? $\endgroup$ – whuber May 11 '16 at 16:13

From the beginning Glen_b's comment was a concern, and I suspect there is a misunderstanding on my part, or something possibly missing in the OP. Here is the thing, if I we have to take your question literally, then it is extremely straightforward. You are saying that order doesn't matter, and that you want the number of combinations (not the probability), such that, choosing $18$ times with replacement from $\small\{0,1,\cdots,9\}$ there are $4$ digits that repeat themselves $3$ times each, and the others are different.

Well, all you have to do is choose $4$ among the $10$ choices in $\small\{0,1,\cdots,9\}$, which are the numbers that will repeat themselves $3$ times each, for a total of $12$ digits. Since you will be left with $6$ digits to choose from, but you are indicating that the other digits appear only once, and we know that the chosen four appear only $3$ times each, all these remaining $6$ will be exhausted. Hence, they offer no additional choice, and your number of possible combinations is ${10\choose 4}=210$.

Or very closely approximated with a simulation:

picks = 0:9 # Digits to choose from.

combinations = function(n){
  matrix = matrix(rep(0, 18 * n), nrow = n) # Starting an empty matrix.

 # we run a loop sampling 18 digits in every iteration:

    for(i in 1:n){    # n is the number of experiments we will carry out.
    lotto = sample(picks, 18, replace = T) # We pick 18 with replacement...
    matrix[i,] = lotto # and fill the matrix one row at a time.

  # Now we want to just keep the rows that have 8 duplicates:
  # 4 digits have 2 duplicates each; hence, 4 x 2 = 8:

  duplicates=apply(apply(matrix, 1, function(x) duplicated(x)), 2, function(x) sum(x))
  matrix = matrix[duplicates==8,]

  # We place the rows of the matrix in increasing order:
  matrix = unique(t(apply(matrix, 1, function(x) sort(x))))

  # And we keep those unique rows that contain 4 groupings of 3 repeat digits:
  matrix = unique(matrix[apply(matrix, 1, function(x) sum(tabulate(rleid(x))==3))==4,])

  # In a sufficiently large simulation the number of rows 
  # of the resulting matrix will be the answer to the question:

which yields $207$.

And just for clarity, this is what two rows of the matrix in the function look like:

enter image description here

Although the order may seem to come into play, it is just a coding "trick" to get the combinations being asked in the OP, which I interpreted as "order does not matter." In other words, we could just as well now shuffle the order of the elements in each row.

| cite | improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.