Suppose we would like to throw nn balls into nn bins uniformly at random. We claim that the bin with maximum load has Θ(ln⁡nln⁡ln⁡n)\Theta( \frac{\ln n}{\ln \ln n}) ball with high probability.

Preliminary

For all x≥0x \ge 0, it holds that

ex=1+x+x22!+...≥xkk!. e^x = 1 + x + \frac{x^2}{2!} + ...\ge \frac{x^k}{ k! }.

For all x∈Rx \in \mathbb{R}, 1+x≤exp⁡(x)1 + x \le \exp (x). Therefore for all n∈N+n \in \mathbb{N}_+,

(1+1n)n≤exp⁡(1n⋅n)=e, \left( 1 + \frac{1}{n} \right)^n \le \exp \left( \frac{1}{n} \cdot n \right) = e,

and for n>1n > 1,

(n−1n)n−1=1(1+1n−1)n−1≥1e. \left( \frac{ n - 1}{n} \right)^{n - 1} = \frac{1}{ \left( 1 + \frac{1}{n - 1} \right)^{n - 1} } \ge \frac{1}{e} .

For n∈N+n \in \mathbb{N}_+, k∈[n]k \in [n],

(nk)kknk≤(1+kn)n=ek. \binom{n}{k} \frac{k^k}{n^k} \le \left( 1 + \frac{k}{n} \right)^n = e^k.

For n∈N+n \in \mathbb{N}_+, k∈[n]k \in [n],

(nk)=n(n−1)…(n−k+1)k(k−1)…1≥nkkk. \binom{n}{k} = \frac{n (n - 1) \ldots (n - k + 1) }{k (k - 1) \ldots 1} \ge \frac{n^k}{k^k}.

Upper Bound

Via union bound, the probability that a particular bin receives at least kk balls is given by

Pr⁡[∃k balls in the bin]≤(nk)1nk≤1k!≤ekkk, \Pr[ \exists k \text{ balls in the bin} ] \le \binom{n}{k}\frac{1}{n^k} \le \frac{1}{k!} \le \frac{ e^k }{ k^k},

We want to find a kk, such that

(ek)k=1n2. \left( \frac{e}{ k} \right)^k = \frac{1}{n^2}.

Taking ln⁡\ln of both sides,

kln⁡k−k=2ln⁡n   ⟹  kln⁡k∈Θ(ln⁡n)   ⟹  ln⁡k∈Θ(ln⁡ln⁡n). \begin{aligned} k \ln k - k = 2 \ln n\, \implies k \ln k \in \Theta( \ln n)\, \implies \ln k \in \Theta( \ln \ln n). \end{aligned}

(By using asymptotically notations, the relationship only holds for reasonably large enough kk and nn.)

Substituting ln⁡k∈Θ(ln⁡ln⁡n)\ln k \in \Theta( \ln \ln n) into kln⁡k∈Θ(ln⁡n)k \ln k \in \Theta( \ln n), we get

k∈Θ(ln⁡nln⁡ln⁡n). k \in \Theta\left( \frac{\ln n}{\ln \ln n} \right).

Finally, by union bound over the number of possible bins, the probability that there is a bin which receives ≥k\ge k ball is bounded by 1/n1 / n.

Lower Bound

Given k∈N+k \in \mathbb{N}_+, define the indicator variables XiX_i for the event that the ii-th bin receives exactly kk balls, and let X=∑XiX = \sum X_i. Then

Pr⁡[Xi=1]=(nk)1nk(1−1n)n−k≥nkkk⋅1nk⋅(n−1n)n−1≥1kk1e. \begin{aligned} \Pr[X_i = 1] = \binom{n}{k}\frac{1}{n^k} \left( 1 - \frac{1}{n} \right)^{n - k} \ge \frac{n^k}{k^k} \cdot \frac{1}{n^k} \cdot \left( \frac{ n - 1}{n} \right)^{n - 1} \ge \frac{1}{k^k} \frac{1}{e}. \end{aligned}

and

Pr⁡[Xi=1]=(nk)1nk(1−1n)n−k≤(nk)1nk≤(en)kkk1nk=ekkk. \begin{aligned} \Pr[X_i = 1] = \binom{n}{k}\frac{1}{n^k} \left( 1 - \frac{1}{n} \right)^{n - k} \le \binom{n}{k} \frac{1}{n^k} \le \frac{ (en)^k }{ k^k } \frac{1}{n^k} = \frac{e^k}{k^k}. \end{aligned}

We shall prove that Cor(Xi,Xj)<0, ∀i≠j\mathbb{Cor}(X_i, X_j) < 0,\, \forall i \neq j. Intuitively, that bin ii obtains ball makes it more difficult for bin jj to obtain ball. It follows that

E[X]=∑E[Xi]≥n⋅1kk1e.Var[X]=∑i∈[n]Var[Xi]+∑i≠jCor(Xi,Xj)≤∑i∈[n]Var[Xi]≤∑i∈[n]E[Xi2]=∑i∈[n]E[Xi]≤n⋅ekkk. \begin{aligned} \mathbb{E}[X] &= \sum \mathbb{E}[X_i] \ge n \cdot \frac{1}{k^k} \frac{1}{e}. \\ \mathbb{Var}[X] &= \sum_{ i \in [n] } \mathbb{Var}[X_i] + \sum_{i \neq j} \mathbb{Cor}(X_i, X_j) \\ &\le \sum_{ i \in [n] } \mathbb{Var}[X_i] \le \sum_{ i \in [n] } \mathbb{E}[X_i^2] \\ &= \sum_{ i \in [n] } \mathbb{E}[X_i] \le n \cdot \frac{e^k}{k^k}. \end{aligned}

By Chebyshev Inequality, we have

Pr⁡[X≤0]≤Pr⁡[∣X−E[X]∣≥E[X]]≤Var[X]E[X]2≤(n⋅1kk1e)/(n⋅ekkk)2=(ke)k⋅1en. \begin{aligned} \Pr[ X \le 0] &\le \Pr[ |X - \mathbb{E}[X]| \ge \mathbb{E}[X] ] \\ &\le \frac{ \mathbb{Var}[X] }{ \mathbb{E}[X]^2} \le \left( n \cdot \frac{1}{k^k} \frac{1}{e} \right) / \left( n \cdot \frac{e^k}{k^k} \right)^2 = \left( \frac{ k }{ e } \right)^k \cdot \frac{1}{en}. \end{aligned}

If we set k=(1/3)⋅(ln⁡n)/(ln⁡ln⁡n)k = (1 / 3) \cdot ( \ln n ) / ( \ln \ln n ), then (k/e)k≤(ln⁡n)k=n1/3(k / e)^k \le ( \ln n)^k = n^{1/3} and

Pr⁡[X≤0]≤e−1⋅n−2/3. \begin{aligned} \Pr[ X \le 0 ] \le e^{ -1 } \cdot n^{ - 2 / 3}. \end{aligned}

Remark. For this setting of kk,

E[X]≥(n⋅1kk1e)≥e−1n2/3. \mathbb{E}[X] \ge \left( n \cdot \frac{1}{k^k} \frac{1}{e} \right) \ge e^{-1} n^{2/ 3}.

As in expectation there are e−1n2/3e^{-1} n^{2/ 3} such bins, it seems that we are likely to find one. But this alone is not enough to guarantee that XX does not deviate from its expectation much. To see why this might cause a problem, consider the random variable YY such that

Pr⁡[Y=e−1n5/3]=1n,Pr⁡[Y=0]=1−1n. \begin{aligned} \Pr[Y = e^{-1} n^{ 5 / 3} ] = \frac{1}{n}, \quad \Pr[Y = 0 ] = 1 - \frac{1}{n}. \\ \end{aligned}

YY has expectation E[Y]=e−1n2/3\mathbb{E}[Y] = e^{ - 1} n^{ 2 / 3}, but is very likely to be 00. The problem with YY is that it has large variance.

Fact. For i≠ji \neq j, Cor(Xi,Xj)<0\mathbb{Cor}(X_i, X_j) < 0

Proof.

Cor(Xi,Xj)=E[XiXj]−E[Xi]⋅E[Xj]=Pr⁡[Xi=1,Xj=1]−E[Xi]⋅E[Xj]=(nk)(n−kk)1nk1nk(1−2n)n−2k−E[Xi]⋅E[Xj]<(nk)(nk)1nk1nk(1−1n)n−k(1−1n)n−k−E[Xi]⋅E[Xj]=E[Xi]⋅E[Xj]−E[Xi]⋅E[Xj]=0. \begin{aligned} \mathbb{Cor}(X_i, X_j) &= \mathbb{E} [ X_i X_j ] - \mathbb{E} [X_i] \cdot \mathbb{E} [X_j] \\ &= \Pr[X_i = 1, X_j = 1] - \mathbb{E} [X_i] \cdot \mathbb{E} [X_j] \\ &= \binom{n}{k} \binom{n - k}{k} \frac{1}{n^k} \frac{1}{n^k} \left( 1 - \frac{2}{n} \right)^{n - 2k} - \mathbb{E} [X_i] \cdot \mathbb{E} [X_j] \\ &< \binom{n}{k} \binom{n}{k} \frac{1}{n^k} \frac{1}{n^k} \left( 1 - \frac{1}{n} \right)^{n - k} \left( 1 - \frac{1}{n} \right)^{n - k} - \mathbb{E} [X_i] \cdot \mathbb{E} [X_j] \\ &= \mathbb{E} [X_i] \cdot \mathbb{E} [X_j] - \mathbb{E} [X_i] \cdot \mathbb{E} [X_j] \\ &= 0. \end{aligned}

□\square

The last inequality follows from that

(n−kk)(1−2n)n−2k=(nk)(n−k)⋯(n−k+1)n⋯(n−k+1)(1−2n)n−2k \begin{aligned} \binom{n - k}{k} \left( 1 - \frac{2}{n} \right)^{n - 2k} &= \binom{n}{k} \frac{(n - k) \cdots (n - k + 1)}{n \cdots (n - k + 1)} \left( 1 - \frac{2}{n} \right)^{n - 2k} \\ \end{aligned}

and that (assuming that k≥2k \ge 2)

(n−k)⋯(n−k+1)n⋯(n−k+1)(1−2n)n−2k≤(n−kn)k(1−2n)n−2k≤(1−2n)n−k≤((1−1n)2)n−k=(1−1n)n−k(1−1n)n−k. \begin{aligned} \frac{(n - k) \cdots (n - k + 1)}{n \cdots (n - k + 1)} \left( 1 - \frac{2}{n} \right)^{n - 2k} &\le \left( \frac{n - k}{n} \right)^k \left( 1 - \frac{2}{n} \right)^{n - 2k} \\ &\le \left( 1 - \frac{2}{n} \right)^{n - k} \\ &\le \left( \Big( 1 - \frac{1}{n} \Big)^2 \right)^{n - k} \\ &= \left( 1 - \frac{1}{n} \right)^{n - k} \left( 1 - \frac{1}{n} \right)^{n - k}. \end{aligned}

Reference

  1. Sanjeev Arora, Cos 521: Advanced Algorithm Design, Lecture 1: Course Intro and Hashing

  2. Sariel Har-Peled, Chapter 4, The Occupancy and Coupon Collector problems.