The ballot experiment concerns an election in which candidate \(A\) receives \(a\) votes and candidate \(B\) receives \(b\) votes, where \(a \gt b\). The votes are assumed to be randomly ordered. The first graph shows the difference between the number of votes for \(A\) and the number of votes for \(B\), as the votes are counted. This process is a random walk in which the initial point \((0, 0)\) and terminal point (\(a + b, a - b)\) are fixed.
The event of interest is that \(A\) is always ahead of \(B\) in the vote count, or equivalently, that the graph is always above the horizontal axis (except of course at the origin). The indicator variable \(I\) of this event is recorded in the first table on each update. The probability density function of \(I\) is shown in blue in the distribution graph and is recorded in the distribution table. On each update, the empirical density function of \(I\) is shown as red in the distribution graph and recorded in the distribution table. The parameters \(a\) and \(b\) can be varied with the input controls.