Created
April 9, 2021 19:09
-
-
Save tvladeck/905b0b02aa1a322f7e7725ade3c54afe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set.seed(1) | |
margins <- c() | |
for(i in 1:1000) { | |
sim <- c() | |
for(j in 1:10) { | |
experts <- rbeta(1000, 1.5, 1) | |
expert_votes <- runif(1000) < experts | |
uninformed <- runif(1000) < .5 | |
sim[j] = sum(expert_votes) + sum(uninformed) - sum(!expert_votes)-sum(!uninformed) | |
} | |
margins[i] = mean(sim) | |
} | |
n_uninformed = 1:1000 | |
plot(margins, pch = 4, xlab = "Number of Uninformed Voters", | |
ylab = "Vote margin") | |
summary(lm(margins ~ n_uninformed)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment