Bayes Formula: If universes were as plentiful as blackberries . . .

An updated version of this demonstration, without Java, is available here.

Suppose we have 101 urns. The first urn has 0 red beads and 100 white beads, the second has 1 red bead and 99 white beads, the third has 2 red beads and 98 white beads, and so on to the 101st urn, which has 100 red beads and 0 white beads.

We choose an urn at random. The probability that we choose the urn with 50 red beads and 50 white beads is 0.5; the probability of choosing any one of the remaining 100 urns is 0.005. We now sample repeatedly, with replacement, from the chosen urn.

After each draw from the urn, the applet recomputes, using Bayes formula, the probabilities that we are sampling from the various urns and plots the probability that we are sampling from the urn with 50 red beads and 50 white beads. The entry for "Red beads:" specifies from which urn the beads are being drawn. The user may enter any integer value from 0 to 100.

When changing the total number of trials run, either press "Enter" after specifying the new value or click on the "Clear" button to reset the scale of the plot.

The probability that we are sampling from the urn with 50 red beads should converge to 1 if we are actually sampling from that urn, and to 0 otherwise. However, if the number of red beads is close to 50, it may take a large number of trials to see the convergence.