Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Evaluation of 538's performance
library('hash')
states = hash()
.set(states,
"CO" = 0.8, "FL" = 0.5, "IA" = 0.84, "NBC2" = 0.87,
"NH" = 0.85, "NC" = 0.74, "VA" = 0.79, "AZ" = 0.98,
"MNC2" = 0.95, "MI" = 0.99, "MT" = 0.98, "NV" = 0.93,
"NM" = 0.99, "OH" = 0.91, "PA" = 0.99, "WI" = 0.97)
run.simulation <- function()
{
num.wrong <- 0
for (key in keys(states))
{
rand <- runif(1)
if(rand > states[[key]]) num.wrong <- num.wrong + 1
}
return(num.wrong)
}
number.wrong <- c()
for(i in 1:10000) results <- append(number.wrong, run.simulation())
hist(number.wrong)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment