Expected Value is 3.5
(1+2+3+4+5+6)/6 = 3.5
Sooner or later, the mean will be 3.5
library(ggplot2)
library(parallel)
x<-1:1000
y<-simplify2array( mclapply(x,
function(i)
mean( simplify2array(mclapply(1:i, function(i) sample(1:6,1))) )
) )
data<-data.frame(x=x, y=y)
plt<-ggplot(data, aes(x,y))+geom_line()
print(plt)
If toss coin==0, casino wins 10 else casio loses 8
Expected value for each game is to make 2 unit money
Sooner or later, casino will make money
library(ggplot2)
library(parallel)
casino=1000
x=c(1:1000)
y=c()
for (i in x){
result<-sample(0:1,1)
casinoProfit<-if (result==0) 10 else -8
casino<-casino+casinoProfit
y<-c(y, casino)
}
data<-data.frame(x=x, y=y)
plt<-ggplot(data, aes(x,y))+geom_line()
print(plt)