Questions tagged [balls-in-bins]

For problems on the distribution of $m$ distinct or identical balls into $n$ distinct or identical bins, optionally with restrictions.

The balls in bins or balls and bins problem is one of the basic problems of computer science, with wide-ranging applications including hashing and load balancing. It asks: if $m$ balls are thrown at random into $n$ bins, then:

  • What is the probability that there is a bin with at least two balls?
  • What is the expected fraction of the bins that are nonempty?
  • What is the expected number of balls per nonempty bin?
  • What is the expected number of bins with more than one ball?

and so forth.

640 questions
40
votes
3 answers

Making 400k random choices from 400k samples seems to always end up with 63% distinct choices, why?

I have a very simple simulation program, the sequence is: Create an array of 400k elements Use a PRNG to pick an index, and mark the element (repeat 400k times) Count number of marked elements. An element may be picked more than once, but counted…
Howard
  • 503
14
votes
2 answers

Balancing balls in bins

The following is a classic problem: There are $k$ bins with $n_1, \ldots, n_k$ balls such that $n_1+\dots+n_k = n$. If $n_i < n_j - 1$, we may move one ball from bin $j$ into bin $i$. By defining the potential function $n_1^2 + \dots + n_k^2$, it is…
Alexi
  • 1,952
  • 1
  • 14
  • 23
14
votes
5 answers

If n balls are thrown into k bins, what is the probability that every bin gets at least one ball?

If $n$ balls are thrown into $k$ bins (uniformly at random and independently), what is the probability that every bin gets at least one ball? i.e. If we write $X$ for the number of empty bins, what is $P(X=0)$? I was able to calculate the $E(X)$…
13
votes
2 answers

Hyper Birthday Paradox?

There are $N$ buckets. Each second we add one new ball to a random bucket - so at $t=k$, there are a total of $k$ balls collectively in the buckets. At $t=1$, we expect that at least one bucket contains one ball. At $t=\sqrt{2N\ln{2}}$, due to…
12
votes
4 answers

Expected max load with $n$ balls in $n$ bins?

If you throw $n$ balls into $n$ bins uniformly and independently at random, let $X$ be the number of balls in the bin with the largest number of balls in it. Is there an elementary way to compute $\mathbb{E}(X)$? This problem comes up when…
user35671
12
votes
2 answers

Balls into bins: expected number of bins attaining the maximum

We are given a multinomial distribution with $k$ bins and $n$ balls. The number of balls is at most the number of bins, i.e., $\sqrt{k} \le n \le k$. The probabilities of throwing a ball into a speficic bin are monotone non-increasing, i.e. $p_1 \ge…
12
votes
2 answers

Closed form for a sum involving binomial coefficients: $\sum\limits_{s=0}^{k} \binom{n}{s} \binom{s}{k-s}$

Let $n,k$ be positive integers. Is there a closed form of the sum $$\sum_{s=0}^{k} \binom{n}{s} \binom{s}{k-s}\text{?}$$ By that I mean a representation which is free of sums and hypergeometric functions or alike. Combinatoric interpretation: This…
12
votes
2 answers

Number of ways to partition $40$ balls with $4$ colors into $4$ baskets

Suppose there are $40$ balls with $10$ red, $10$ blue, $10$ green, and $10$ yellow. All balls with the same color are deemed identical. Now all balls are supposed to be put into $4$ identical baskets, such that each basket has $10$ balls. What is…
11
votes
3 answers

How can I solve bins-and-balls problems?

Below is the problem that I wanted to solve When there are $m$ balls and $n$ bins, balls are thrown into bins where each ball is thrown into a bin uniformly at random. What is the expected number of bins that contain strictly more than 1…
John
  • 123
  • 1
  • 1
  • 5
11
votes
2 answers

$n$ balls are thrown randomly into $k$ bins - how many are empty?

A large number of variants of this question were already asked here, including these - one, two, which are close, but none seem to answer my question. Assume that $n$ balls are thrown randomly and independently into $k$ bins. What is the…
10
votes
3 answers

Probability $k$ bins are non-empty

The following problem arises in the analysis of Bloom filters. Consider $m$ bins and $N=nk$ balls placed uniformly and independently at random into the bins. A query chooses $k$ bins uniformly and independently at random and asks if they are all…
user35671
10
votes
4 answers

Expected value of size of subset

Given a set $S$ such that $|S|=n$, A random item is chosen randomly from $S$, and being appended to a new set $T$. This process is being repeated $n$ times (with repetition), what is the expected value of $|T|$ ?
Uri Goren
  • 2,950
9
votes
1 answer

How many expected people needed until 3 share a birthday?

I asked a somewhat related question recently and then became interested in this one: how many people are required, on average, until 3 share a birthday? More generally, if we have $M$ bins, what is the expected number of balls we must toss before…
Fixee
  • 11,760
9
votes
2 answers

Find: The expected number of urns that are empty

A total of $n$ balls, numbered $1$ through $n$, are put into $n$ urns, also numbered $1$ through $n$ in such a way that ball $i$ is equally likely to go into any of the urns $1, 2, . . . , i$. Find the expected number of urns that are empty. Can…
user63192
  • 1,091
9
votes
4 answers

Probability that all bins contain strictly more than one ball?

Here's the problem I'm working on: Given that I'm distributing $N$ balls into $K$ bins, what is the probability that all bins contain at least two (strictly more than 1) balls? This seems like a very similar question to asking what the probability…
1
2 3
42 43