Take a look at
xkcd's election predictor. It scrapes a bunch of election outcome probabilities per state from intrade and uses them to provide a prediction for the overall election. It does so by using a Monte Carlo simulation, given the probabilities, it runs a mock election assuming each state outcome is independent a whole bunch of times with
(
Read more... )
Comments 12
Reply
The original code tried to put the largest number first. Your code puts it last. You want sorted(l, reverse=True).
Reply
Reply
If you're interested in solid Monte-Carlo analysis, you probably can't do better than 538.
Reply
This site uses an algorithm similar to the one I described, but (maybe?) a bit faster and more complicated. From their FAQ.
In general, the probability distribution for all possible outcomes is given by the coefficients of the polynomial
((1 - P1) + P1 * x^EV1) * ((1 - P2) + P2 * x^EV2) * … * ((1 - P51) + P51 * x^EV51)
Reply
-Chris
Reply
Reply
Reply
Reply
Go figure.
Reply
Leave a comment