Herešs a possible approach. Išll illustrate with 10 units and up to 10
allotments.
Suppose Rand chooses 10 allotments. As you said, then there can only be
1 unit in each allotment.
Suppose Rand chooses 9 allotments. Each allotment must contain at least
one unit, so put one unit in each of the 9 allotments. This leaves 10 -
9 = 1 unit to place. Use Rand to choose a number from 1 to 9 and put
that one unit there.
Suppose Rand chooses 8 allotments. Each allotment must contain at least
one unit, so put one unit in each of the 8 allotments. This leaves 10 -
8 = 2 units to place. This can be done in two ways. Either put two
units in a random choice among the 8 allotments or put one unit in a
random choice and the other unit in a second random choice of the 8
allotments. If you want equal probabilities of storage selections, that
second random choice cannot be the same as the first one.
With 7 allotments there will be 10 - 7 = 3 units to place. Here you
have to partition 3:
3 + 0 = 3
2 + 1 = 3
1 + 1 + 1 = 3
and use Rand to choose one of the partitions, then use Rand the number
of times necessary to distribute that partition of units.
One can go on, but you can already see the problem presented by a large
number of units. If you have n units and m allotments, then you must
place n - m = k units. If k is large you must devise a method to
randomly generate one partition out of the many that are possible. That
partition itself may contain many numbers, and those units must be
randomly placed as previously illustrated. That might take a lot of
computer time.