Created
September 18, 2018 19:08
-
-
Save duarteguilherme/15891e272878e68a1b62ca5dfa210c45 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
# Simulando probabilidades | |
# Teste | |
simula_eleicoes <- function(sd) { | |
ns <- seq(0.25, 0.75, 0.001) | |
v <- purrr::map_dbl(ns, ~ mean( | |
ifelse( | |
rnorm(n = 100000, mean = .x, sd = sd) > .5 | |
, 1, 0 ) | |
) | |
) | |
tibble(ns = ns, v = v) | |
} | |
ggplot2::qplot(data = simula_eleicoes(0.01), ns, v, geom = "line") + ggplot2::theme_bw() + scale_x_continuous(breaks = seq(0, 1,0.02)) + | |
labs(x = "porcentagem", y = "probabilidade_vitoria") | |
ggplot2::qplot(data = simula_eleicoes(0.03), ns, v, geom = "line") + ggplot2::theme_bw() + scale_x_continuous(breaks = seq(0, 1,0.02)) + | |
labs(x = "porcentagem", y = "probabilidade_vitoria") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment