sapply(c("pipeR", "dplyr", "tidyr", "ggplot2", "readr", "readxl", "Cairo", "grid", "gridExtra"),
require, character.only = TRUE)
勝つ確率が0.5の時に17勝する確率は
dbinom(17, 20, 0.5)
options(repr.plot.width = 4, repr.plot.height = 4)
data.frame(x = c(0:20), y = dbinom(c(0:20), 20, 0.5)) %>>%
ggplot(aes(x = x, y = y)) +
geom_point()
pbinom(c(0:20), 20, 0.5) %>>% round(digit = 4)
棄却域は15勝以上
data.frame(win = c(0:20), prob = pbinom(c(0:20), 20, 0.5)) %>>% filter(prob >= 0.95)
$p$値は
pbinom(16, 20, 0.5, lower.tail = FALSE)
10回中7回的中は1/3より高いか
棄却域は7回以上
data.frame(x = c(0:10), prob = pbinom(c(0:10), 10, 1/3)) %>>% filter(prob >= 0.95)
pbinom(6, 10, 1/3, lower.tail = FALSE)
devtools::session_info()