23/03/03 20:09:22.67 uj9VyuTDH.net
sim=\(A,p=(1:6)/21){ # A:Award p:probability
d=sample(6,1,prob=p) # d: pip of dice
m=ifelse(d==1,A,-d) # m: money balance
while(d!=1){
d=sample(6,1,prob=p)
m=m+ifelse(d==1,A,-d)
}
m
}
k=1e5
y=replicate(k,sim(20))
# (1)
mean(y)
BEST::plotPost(y)
hist(y,breaks='scott',border=2,main='',axes=F,xlab='損益(万円)',ylab='') ; axis(1)
summary(y)
which.max(table(y)) |> names() |> noquote()
# (2)
mean(y>0)
# (3)
mean(y>=10)