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.

519 questions
37
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
  • 473
  • 4
  • 6
15
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)$…
Colonel Panic
  • 1,300
  • 3
  • 12
  • 28
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…
11
votes
3 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…
graffe
  • 4,424
  • 2
  • 18
  • 50
11
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…
graffe
  • 4,424
  • 2
  • 18
  • 50
11
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
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,900
  • 10
  • 26
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
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,199
  • 6
  • 39
  • 64
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,081
  • 8
  • 18
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…
9
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…
8
votes
3 answers

I've clicked XKCD's "random" button k times and I've already seen all of them. What's the expected number of XKCD's I've seen?

This seems like a modification of the coupon collector's problem which can be stated as follows: There are $n$ coupons total to collect. Given that the past $k$ coupons seen I've already collected (coupons are collected with replacement), what's the…
8
votes
3 answers

Second pair of matching birthdays

The "birthday problem" is well-known and well-studied. There are many versions of it and many questions one might ask. For example, "how many people do we need in a room to obtain at least a 50% chance that some pair shares a birthday?" (Answer:…
Fixee
  • 11,199
  • 6
  • 39
  • 64
8
votes
3 answers

A combinatorial identity - Hockey Stick generalization

There is a well known identity (the so called "Hockey-stick identity") asserting that: $$\sum_{j=0}^m \binom{r+j}{j} = \binom{m+r+1}{r+1}$$ For some proofs see this. I need to prove a kind of generalization, namely: $$\sum_{j=0}^m…
1
2 3
34 35