Pólya Urn Simulator

Mathematical Model

An urn holds balls of \(m\) colours, \(a_i\) of colour \(i\), \(A = \sum_i a_i\) in all. At each draw a ball is taken uniformly at random and returned together with \(k\) new balls of the same colour, so a colour that is drawn becomes more likely to be drawn again:

$$P(\text{draw } i) = \frac{a_i(n)}{A + nk}, \qquad a_i(n+1) = a_i(n) + k \ \text{ if } i \text{ is drawn}$$

Watch a single urn lock in under One urn, then compare the spread of many independent urns with the Beta law under Many urns.

Parameters:
m: Number of colours
ai: Initial balls of colour i
k: Balls added back per draw
n: Number of draws
Trials: Independent urns

Parameters

Between 2 and 8
Small urns give the widest limits
Strength of the reinforcement
Shared by both tabs

The drawn ball is ringed and the balls returned with it are outlined; new balls land on top. Dotted lines mark the initial fractions, which are also the expected fractions after any number of draws. Past 400 balls the urn shows an evenly spaced sample of its contents. Same seed, same path.