Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Akiyah/7808369 to your computer and use it in GitHub Desktop.
Save Akiyah/7808369 to your computer and use it in GitHub Desktop.
実践ハンバーガー統計学! マクドナルドのポテトSを10個食べて信頼区間を推定した #vgadvent2013
x <- c(53,46,55,53,61,58,40,56,49,42)
var(x) # 不偏分散
# => 47.56667
mean(x) # 平均
# => 51.3
std <- function(x) sd(x)/sqrt(length(x))
std(x) # 標本標準誤差
# => 2.180978
t <- qt(0.05/2, 10-1, lower=F) # サンプルサイズは10なので自由度は9。95%信頼区間を求める。
# => 2.262157
max <- mean(x) + t * std(x)
# => 56.23372
min <- mean(x) - t * std(x)
# => 46.36628
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment