HW 3 - Central Limit Theorem -

Consider the ancient game of “craps” described on page 70. It involves the use of two 6-sided dice, and in its simplest form the two dice are thrown and the two scores added together.

If so, please give a brief description of the game/situation and explain/show how it would confirm the CLT.

# id number
id <- 04381*10
score <- 2:12

ways <- c(1,2,3,4,5,6,5,4,3,2,1)

game <- rep(score,ways)

game
##  [1]  2  3  3  4  4  4  5  5  5  5  6  6  6  6  6  7  7  7  7  7  7  8  8
## [24]  8  8  8  9  9  9  9 10 10 10 11 11 12
sample(game,1)
## [1] 9
outcome <- numeric(id)
for (i in 1:id) 
{
  outcome[i] <- sample(game,1) 
}

hist(outcome,breaks=(1.5:12.5))

mean.score <- numeric(id)
for (i in 1:id) mean.score[i] <- mean(sample(game,3))
hist(mean.score,breaks=(1.5:12.5))

mean(mean.score)
## [1] 6.998805
sd(mean.score)
## [1] 1.359584

The mean and standard deviation are almost the same numbers comparing to books results. It demostrate the central limit theorem

xv <- seq(2,12,0.1)

yv <- id*dnorm(xv,mean(mean.score),sd(mean.score))

hist(mean.score,breaks=(1.5:12.5),ylim=c(0,15000),col="yellow",main="")

lines(xv,yv,col="red")

*The coin example was created in conjunction with Gabriella B.

# 0 : tails
# 1 :  heads
# 10000 people throwing the coin 10 times
# sum tails
outcome <- numeric(10000)
for(i in 1:10000) outcome[i] <- sum(sample(0:1,10,rep=T))
hist(outcome, breaks=(-0.5:10.5))

mean(outcome)
## [1] 4.9815
sd(outcome)
## [1] 1.560577