你需要两个replace=TRUE
和prob
- 参数设置为您选择的非等概率设置。
throws <- sample(1:6, 44, replace=TRUE, prob=c(1,1,1,1,1,2)/7 )
# Two realizations
> throws <- sample(1:6, 44, replace=TRUE, prob=c(1,1,1,1,1,2)/7 )
> table(throws)
throws
1 2 3 4 5 6
10 5 8 7 3 11
> throws <- sample(1:6, 44, replace=TRUE, prob=c(1,1,1,1,1,2)/7 )
> table(throws)
throws
1 2 3 4 5 6
7 3 4 8 7 15
请注意,结果仍然是(伪)随机的,并且仍然有可能偏离天真的概率学生的预期。我无法抗拒迂腐的纠正,认为这是针对单个骰子而不是复数的“骰子”。