3

Consider the problem of throwing balls uniformly at random into $q$ bins, each has capacity $q$. What is the expected number of balls we need to throw until one of the bins becomes full?

Clearly the expectation is between $q$ and $q(q-1)+1$. My idea is as follows:

$$ L_n:= \text{event that at time $n$ the first full bin occurs} $$

Then some bin $i$ has $q$ balls and others have at most $q-1$ balls. We want to find the expected total number of balls thrown, i.e. the sum of the number of balls in all bins.

1 Answers1

3

I am assuming you are throwing the balls one by one. So The balls are distinguishable and the bins are distinguishable. So we want to know what is the probability that at step $k$ we make one of the bins full so we pick out of the $k-1$ past balls $q-1$ to put in the bag with the $k-$th ball we can do this in $\binom{k-1}{q-1}$ and then we choose $l$ bags that contain balls and we proceed to fill them with the remaining $k-q$ balls, we can do this using the Restricted Stirling numbers of the second kind defined by ${a\brace b}_{\leq c}$ as the number of partitions of $[a]$ into $b$ blocks each block having at most $c$ elements. The formula ends up being $$\sum _{k=1}^{\infty}\frac{k}{q^{k-1}}\binom{k-1}{q-1}\sum _{l=0}^{q-1}\binom{q-1}{l}l!{k-q\brace l}_{\leq q-1}.$$ Notice that the $q/q^k$ comes from the uniform probability and choosing the bin in which the $k-$th ball is thrown.

I simulated it with the following code

s = 0
q = 23
P = [1/q]*q
N=5000
X = GeneralDiscreteDistribution(P)
for n in range(0,N):
    T =[0]*q
    si = true
    v = 0
    while si:
        r = X.get_random_element()
        T[r]+=1
        v+=1
        if T[r]==q:
            s = s+v
            break
print((s/N).n())

Giving me the following results, where the values are $q,$ the simulation and the value of the function above.

1 1.00000000000000 1.00000000000000
2 2.49920000000000 2.50000000000000
3 5.04460000000000 5.04938271604938
4 8.68720000000000 8.73054122924805
5 13.6078000000000 13.6094031969059
6 19.7122000000000 19.7373839637175
7 27.2410000000000 27.1558404831146
8 36.0150000000000 35.8990016941469
9 45.8734000000000 45.9958517253838
10 57.5808000000000 57.4713838216979
11 70.0928000000000 70.3474684480954
12 84.6120000000000 84.6434754434209
13 100.547800000000 100.376733269055
14 117.507800000000 117.562876618811
Phicar
  • 14,722
  • Nice intuitive solution (+1)! Is ${k-q\brace l}_{\leq q-1} = 0$ for $k-q < 0$? – Varun Vejalla Jul 12 '20 at 02:40
  • Thanks, yes exactly like that. If you want i follow recursion 1.2 in https://arxiv.org/pdf/1707.08138.pdf – Phicar Jul 12 '20 at 13:41
  • Do you happen to have the exact rational forms for the small $q$ in the table? Maybe the numerators/denominators will be in the OEIS. – Varun Vejalla Jul 12 '20 at 17:34
  • The denominators are $q^{(q-1)^2},$ the numerators are not in the OEIS. I checked too. The first 5 terms of the numerators are $1,5,409,2288659,2076630126481$ – Phicar Jul 12 '20 at 17:40