Created
December 9, 2015 12:41
-
-
Save mokjpn/9637ca00fbc7457287b9 to your computer and use it in GitHub Desktop.
早押しクイズでn問先取の時,問題をx問用意した時にどのくらいの確率で勝ち抜け者が出るか.ただし一人も正解がない場合はないものとする.
This file contains hidden or 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
# 早押しクイズでn問先取の時,問題をx問用意した時にどのくらいの確率で勝ち抜け者が出るか.ただし一人も正解がない場合はないものとする. | |
nquiz <- function(x,n) { | |
if(n > x) { | |
stop("n must be smaller than or equal to x") | |
} | |
sum(sapply(n:x, function(xx) { ncol(combn(x,xx))})) / (2^x) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment