我可以通过以下方式完成此操作。
throws = 10000
dieone = function(n) sample(1:6, n, rep = T)
dietwo = function(n) sample(1:6, n, rep = T)
diethree = function(n) sample(1:6, n, rep = T)
diefour = function(n) sample(1:6, n, rep = T)
die1 <- dieone(throws)
die2 <- dietwo(throws)
die3 <- diethree(throws)
die4 <- diefour(throws)
dice <- die1 + die2 + die3 + die4
h <- hist(dice)
我想使用for
循环或其他可以做我想要的骰子的东西。