This app models Pólya's urn experiment. An urn initially contains \(a\) red and \(b\) green balls. On each trial, a ball is selected at random from the urn, and then replaced along with \(c\) new balls of the same color. In this simulation, the red balls are numbered consecutively \((1, 2, \ldots)\) and the green balls are numbered consecutively in the same manner. The sample of balls in \(n\) trials is shown in the left graph box. Random variable \(Y\) gives the number of red balls selected after \(n\) trials, \(M = Y / n\) gives the proportion of red balls selected in the \(n\) trials, and \( Z = (a + c Y) / (a + b + c n)\) the proportion of red balls in the urn. These are recorded on each update in the data table. As a function of \( n \), the proportion \( Z \) is a martingale.
The probability density function and moments of \(Y\) are shown in blue in the distribution graph and are recorded in the distribution table. On each update, the empirical density function and moments of \(Y\) are shown in red in the distribution graph and are recorded in the distribution table. The parameters \(a\), \(b\), \(c\), and \(n\) can be varied with the input controls.