Simulating the 2008 U.S. Presidential Election

We use recent polling data (current as of the middle of August 2008) to simulate the results of the upcoming November 2008 U.S. presidential election. We focus on the allocation of votes in the Electoral College rather than the popular vote. To generate a simulation, press the "resimulate" button, change the strength of state-specific polling effects, or change the strength of a national random swing in the polls between now and election day.
In the live version of this Demonstration, placing your mouse over the states in the graphic shows the name of the state, the number of electoral votes possessed by the state (in parentheses), and the recent actual polling results for that state from Electoral-vote.com. Notice that there may be a difference between the current polling leader in the state and the ultimate winner of the state's electoral votes (indicated by red for McCain and blue for Obama). This effect will occasionally be observed because the simulation captures: (a) the uncertainty of information obtained through polling results that do not ultimately predict the results on election day; and (b) changes in voter preferences between now and election day.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


The polling data for this Demonstration is taken from Electoral-vote.com, which averages all reasonably reliable state-by-state polling results that were published within the last week (though in states like Idaho, where little polling is ever done, the web site uses very stagnant polling data). This Demonstration uses the polling data available at the approximate time of initial publication, and the authors will try to update the polling data periodically prior to the election in November. Feel free to download the Demonstration and change the polling data in particular states to results that you find to be more suitable.
The simulation does not account for other longer-term factors that tend to influence voting results—factors like race, religion, income level, education, etc. Additionally, the polls used to aggregate smoother polling results at Electoral-vote.com include both polls of "likely voters" (voters who say they will actually vote, and who have voted in recent elections) and registered voters. Polls of registered voters tend to favor Democratic candidates, since Democratic candidates often orchestrate voter registration drives that may or may not result in voters actually showing up at the polls on election day.
First, we generate a random Gaussian number with standard deviation equal to half of whatever the user chooses as the "strength of national random swing". Half of this result (which can be a positive or negative number) is added to Obama's polling number in each state and the same number is subtracted from McCain's polling number in each state. Again, since the random Gaussian can be negative, subtracting a negative number would have the consequence of improving McCain's polling numbers in the state. The net effect of this procedure is to widen or narrow the current gap between the candidates in each state in exactly the same way (hence it is a "national" effect) between now and election day.
The new polling data is then subjected to a rule, which we term the "strength of state-specific random swing". Let be the strength of the state-specific random swing. If the user selects , then the state's electoral votes are awarded to the current leader in the polls, using the new polling data. If the user selects , then the state's electoral votes are awarded to the current poll leader only if the new polling data in the state shows the polling leader leading by five or more points.
If the difference between the percentage of voters favoring Obama and McCain is less than (again, using the new polling data), then the state's electoral votes are randomly assigned to Obama with probability , where and are the recent polling results for Obama and McCain, respectively.
To obtain landslide effects, make the national random swing variable higher rather than lower. To obtain noisy results on a state-by-state basis, make the national random swing variable relatively small and make the state-specific random swing relatively large.
Notice that the polling results in each state do not add up to 100% because some voters are undecided. We also ignore the possible splitting of Maine or Nebraska's electoral votes.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2014 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+