我如何在R中编写一个FOR LOOP

set.seed(1404)
payout < - c()
for (i in 1:5000) {
payout_vector[i] ,-sample (1:20, size = 1)

}

}
payout_vector
round(mean(payout),3)

#These are my questions. I have no idea what I am doing in R. #Let us now use R to simulate, so mimic, the dart-throwing monkey and the corresponding payouts 5000 times.

这5000个模拟的平均支出是多少? 有什么差异? 如果X是衡量支出的随机变量,则E(X)是多少?

评论