User Tools

Site Tools


gibson:teaching:fall-2012:math445:lab8

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

====== Math 445 Lab 8: Presidential election ====== Your job is to predict the outcome of today's Presidential election given the last-minute polling data. Specifically, given a list of states, their electoral votes, the composite polling percentages for each candidate, and the margins of error those polling percentages, you are to run a large number of simulations of the election. For each state, start by assigning the specified composite polling percentages to the two candidates. Then determine a random number in the range between ''-margin'' and ''+margin'', and transfer that percentage from one candidate to the other. Always follow the same sign convention, i.e. if the random number is positive, take the percentage from Obama and give it to Romney. Then award that state's electoral votes to the candidate with the larger percentage of votes. Add up all the electoral votes for each candidate, and award the ''n''th election to the candidate with the greater total number of electoral votes. Run a large number of such simulated elections, and record the number of electoral votes for each candidate in each election. Make a histogram that shows the statistical distribution of total electoral votes for one of the candidates, using bins of width 5 between 0 and 539 (0-4 for bin 1, 5-9 for bin 2, etc). Color the bins corresponding to Romney wins red and the bins corresponding to Obama wins blue. I suggest starting with a small number of simulated elections, say 100 or 1000, and then increasing to a large number (10,000 or 100,000) when your code is debugged and you're confident it's working correctly. Then answer the following questions - Who is most likely to win the presidential election? - What is the probability that the most likely winner will actually win? - What is the most likely range of electoral votes for the winner? (among the bins of width 5 specified above) Turn in print-outs of your codes, your histogram, and your answers to the above questions. Tips: * Start with a small number of simulated elections, say 100, and then increase to a large number (10,000 or 100,000) when you're confident your code is working correctly. * You can also develop your code using simulated data, for example, just ten states with 50-50 chances for each candidate and zero or a very small margin of error. Some further questions you might also address * The margins of error reported in the table are really 95% confidence levels, corresponding to two standard deviations of a Gaussian distribution. Modify your code so that the random number added to each is from a Gaussian distribution with standard deviation of one-half the margin of error. Does this significantly change your results? * Does doubling or halving the margins of error significantly change your results? * How many elections do you need to simulate in order to get reliable answers? * The lab as written assumes a two-party presidential election. Do you think we should include third-party candidates? If you do, does it change the results significantly? * We are trusting that the polling data form an accurate estimate of the actual votes cast, to within the margins of error. Is this a valid assumption? Why or why not? * Do you believe your own election prediction? Why or why not? Relevant matlab commands; **rand**, **randn**, **sum**, **hist**, plus standard plotting commands such as **xlabel**, **ylabel**, **title**. Nate Silver, a sports statistician, pioneered the use of Monte Carlo methods in election prediction during the 2008 elections ([[http://fivethirtyeight.blogs.nytimes.com/]], [[http://en.wikipedia.org/wiki/FiveThirtyEight]]). Note that this lab does not cover the subtlest and most difficult aspect of election prediction: producing good composite poll numbers and margins of error from large numbers of pollsters using different methods, sample sizes, and polling dates. There is quite a bit of controversy in the current election over Mr. Silver's methods and his assessment that Obama has an 80% chance of winning the election. See, for example, [[http://cosmiclog.nbcnews.com/_news/2012/10/30/14809227-political-forecasts-stir-up-a-storm?lite]], [[http://www.dailykos.com/story/2012/11/01/1153661/-Nate-Silver-s-Math-Based-Math]], or google "Nate Silver controversy". Here's some current polling data, taken from [[http://fivethirtyeight.blogs.nytimes.com]] on 2012-11-01. You can load this into Matlab as a matrix ''P'' by cutting and pasting the data into a text file ''P.asc'' and running ''load P.asc'' within Matlab. If you don't believe this polling data, feel free to use something you trust more. <code> % Composite Presidential election polling numbers % from http://fivethirtyeight.blogs.nytimes.com % 2012-11-01 % % O == Obama percentage % R == Romney percentage % M == margin of error % EV == electoral votes % % O R M EV state 36.5 62.9 3.9 9 % AL 38.1 60.1 6.3 3 % AK 45.6 53.4 4.1 11 % AZ 37.9 60.3 4.1 6 % AR 58.2 40.5 3.4 55 % CA 50.1 48.9 3.5 9 % CO 55.9 43.3 3.7 7 % CT 59.4 39.8 5.7 3 % DE 92.7 6.7 3.2 3 % DC 49.4 50.1 3.2 29 % FL 44.9 54.6 3.3 16 % GA 67.0 31.9 4.9 4 % HA 31.4 66.6 4.7 4 % ID 59.3 40.1 3.4 20 % IL 43.8 55.4 3.5 11 % IN 51.0 48.0 3.8 6 % IA 37.4 61.5 6.3 6 % KA 39.9 59.2 4.7 8 % KY 40.6 58.5 6.1 8 % LA 56.1 42.5 4.5 4 % ME 60.4 38.4 3.4 10 % MD 58.9 39.7 4.4 11 % MA 52.9 45.7 3.3 16 % MI 52.8 45.9 3.3 10 % MN 39.1 60.3 5.4 6 % MS 45.1 54.1 3.3 10 % MO 44.1 53.8 4.6 3 % MT 39.2 60.1 3.6 5 % NE 51.3 47.8 3.4 6 % NV 51.0 48.2 4.1 4 % NH 55.0 44.0 3.7 14 % NJ 53.9 45.0 4.0 5 % NM 62.4 36.9 3.2 29 % NY 48.4 51.0 3.0 15 % NC 41.5 57.0 4.3 3 % ND 50.7 48.1 3.2 18 % OH 33.5 66.2 4.0 7 % OK 52.7 44.8 4.0 7 % OR 52.0 46.9 3.0 20 % PA 62.2 36.4 4.9 4 % RI 43.0 56.3 4.7 9 % SC 41.2 57.5 4.9 3 % SD 39.8 59.2 4.6 11 % TN 41.7 57.8 3.6 38 % TX 26.3 71.6 4.4 6 % UT 65.6 33.0 5.2 3 % VT 50.1 49.2 2.9 13 % VA 55.6 43.1 3.9 12 % WA 40.6 58.1 5.2 5 % WV 51.6 47.6 3.4 10 % WI 30.4 68.0 6.3 3 % WY </code>

gibson/teaching/fall-2012/math445/lab8.1351821000.txt.gz · Last modified: 2012/11/01 18:50 by gibson