- 已编辑
这个可能太简单了,在网上搜到了一个示例
prize<-c()
for (i in 1:100000) {
x1<-sample(c(0,1,2,3,4,5),50,replace = TRUE,prob = c(0.29,0.25,0.1,0.15,0.2,0.01))
win<-c(1:5) %in% x1
prize=sum(win) #(等于5,集齐五福)
}
table(prize)#39244/100000=39.2%
如果大家有别的方法,欢迎回复,感激不尽