Created
May 21, 2012 15:20
-
-
Save doryokujin/2762883 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
# 10回のコイン投げを100セット繰り返したときの,表の出た回数の分布。 | |
> n <- 10; x <- seq(0,10); set <- 100; | |
> hist(rbinom(set,n,0.5), breaks=x, probability=TRUE, xlab='set=100,n=10') | |
> lines(x, dnorm(x, n/2, sqrt(n*0.5*0.5)), col="red") | |
# 20回のコイン投げを100セット繰り返したときの,表の出た回数の分布。 | |
> n <- 20; x <- seq(0,20); set <- 100; | |
> hist(rbinom(set,n,0.5), breaks=x, probability=TRUE, xlab='set=100,n=10') | |
> lines(x, dnorm(x, n/2, sqrt(n*0.5*0.5)), col="red") | |
# 1000回のコイン投げを10000セット繰り返したときの,表の出た回数の分布。 | |
> n <- 1000; x <- seq(400,600); set <- 10000; | |
> hist(rbinom(s,n,0.5), breaks=x, probability=TRUE, xlab='set=10000,n=1000') | |
> lines(x, dnorm(x, n/2, sqrt(n*0.5*0.5)), col="red") | |
# σ=100 の指数分布の,n=1,10,100個のサンプル平均の分布(各1000セット) | |
> calc.mean <- function(n){ sum(rexp(n,0.01))/n } | |
> hist(sapply(rep(1,1000),calc.mean)) | |
> hist(sapply(rep(10,1000),calc.mean)) | |
> hist(sapply(rep(100,1000),calc.mean)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment