## build probability histograms for roulette example ## ADM 10/3/2007 ############################# ## betting red ## specifics the.box <- c(rep(1,18), rep(-1,20)) draws <- 100 ## perform simulation G <- 10000 holder.1 <- rep(NA, G) for(g in 1:G) { holder.1[g] <- sum(sample(the.box, draws, replace=TRUE)) } ############################# ## betting seventeen ## specifics the.box <- c(35, rep(-1,37)) draws <- 100 ## perform simulation G <- 10000 holder.2 <- rep(NA, G) for(g in 1:G) { holder.2[g] <- sum(sample(the.box, draws, replace=TRUE)) } par(mfrow=c(2,1)) hist(holder.1, xlim=c(-100, 250), freq=FALSE) hist(holder.2, xlim=c(-100, 250), freq=FALSE)