Is Pythons random.randint statistically random?

前端 未结 6 2122
悲哀的现实
悲哀的现实 2020-12-16 06:00

So I\'m testing an calculating the probabilities of certain dice rolls, for a game. The base case if that rolling one 10sided die.

I did a million samples of this,

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 06:09

    These results are very close to what you'd expect, and there's a simple calculation you can do to check that. If you roll 1,000,000 D10s and count the number of 1s (say) the mean of that random variable is 100,000 (number of trials * probability of success) and the variance is 90,000 (number of trials * probability of success * probability of failure), so the standard deviation is sqrt(90,000)=300. So you should expect to get something about 300 away from 100,000, i.e. 10% +/- 0.03%.

提交回复
热议问题