Object Library > Applets > Ballot Experiment
In an election, candidate A receives a votes and candidate B receives b votes, where a > 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. The parameters a and b can be varied with scroll bars.
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 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 of I is shown as red in the distribution graph and recorded in the distribution table.
The ballot problem is historically interesting and is related to the simple random walk. For a mathematical analysis, see
Click on the link below to download the Java archive file:
To add the applet to your web page, insert the following in the html file, at the point where you want the applet to appear:
<applet code="edu.uah.math.experiments.BallotExperiment.class"
archive="BallotExperiment.jar" width="600" height="400"></applet>
The jar file and the html file must be in the same folder.
This width and height dimensions are simply suggestions and can be varied. Generally, components such as graphs and tables expand and contract proportionally, while components such as buttons, scrollbars, dice, and coins are fixed in size.
Copyright © 2001-2003 Kyle Siegrist, Dawn Duehring
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for more details.
If you are interested in the Java source code or the Java documentation and object model for this applet, please visit BallotExperiment in the Object section of the Library.