Hopefully this makes sense.
A good way of generating a list of numbers, with the possibility of numbers either coming up multiple times or not, with weighting possible, is to fill an array with a list of all numbers you want to allow to come up, repeated appropriately for weighting. So, say you have three different numbers, one that you want to come up 5 times in 10, one 3 times in 10 and the last 2 times in 10. You would populate an array like:
array=(1 1 1 1 1 2 2 2 3 3)
Now, if you just wanted to pick randomly, based on the weighting, you would just randomly generate numbers 1 through 10 and use the number at that position. You would have a chance of picking "1" every time, but more the numbers would come out statistically averaging your desired weighting.
If you wanted to force the occurrences, you would do this loop 10 times:
Pick a number from 1 to length(array)
Take the element at the selected position
Remove that element from the array
So, say the first time you selected the number 4. That would give you item '1' and the new array would look like:
array=(1 1 1 1 2 2 2 3 3) (notice it's now 9 in length)
So, now you pick a random number from 1 to 9. Say you pick 5. You get item '2' and the array is now:
array=(1 1 1 1 2 2 3 3)
If you keep doing this until the array is empty you will have picked out your 5 1s, 3 2s and 2 3s in a random order.
This method also works if you want non-repeating numbers. You would just initially populate the array with n different numbers.
This is a much faster method than checking to see if you've picked a number before for every number you pick, particularly after you've picked most of the available numbers.