# Standard deviation of rolling dice

This topic is 4584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have n k-sided dice that I would like to roll. Rather than rolling the n dice (which would take O(n)), I'm going to assume that the distribution is approximately normal (it is) and randomly select a integer z between 0 and 1000, where z/10 is the percentile; this will determine what the simulated value is (and it will be O(1)). In turn, this requires that I know the mean and standard deviation. The mean is easy; it is n(k + 1) / 2. The standard deviation, however, appears to be a bit harder. Using the multinomial distribution appears to be a good start, but I've forgotten how to transform the standard deviation of a specific random variable into a single quantitative value for the whole data. May I simply multiply the standard deviation for each value by the quantitative value itself? thanks,

##### Share on other sites
Have a look here under # 1.2 Estimating standard deviation from a sample. Hope thats what you're looking for.

##### Share on other sites
Quote:
 Original post by MotorherpHave a look here under # 1.2 Estimating standard deviation from a sample. Hope thats what you're looking for.

Not exactly. I don't want the standard deviation of the sample (which is unlikely to be a perfect distribution); I want the standard deviation of the distribution itself. It needs to be O(1), so I don't want to calculate anything that has to do with obtaining n samples.

##### Share on other sites
You can compute the variance of the distribution of rolling a single die. The result is (k^2-1)/12. I think the variances should add up, so the variance of the sum of n k-sided dice should be n*(k^2-1)/12. The standard deviation is the square root of that.

##### Share on other sites
Quote:
 Original post by alvaroYou can compute the variance of the distribution of rolling a single die. The result is (k^2-1)/12. I think the variances should add up, so the variance of the sum of n k-sided dice should be n*(k^2-1)/12. The standard deviation is the square root of that.

That worked perfectly, thank you. Deviations from the predicted values are less than one part per million in 10,000 trials. ++rate!

##### Share on other sites
Considering the mersene twister is so fast, and you can easily transparently perform the trick with sliding view, this is rather bad idea, if you are not rolling 1000, or rather 10000 dices.
Also note if you will roll these dices, you could get precise result. Rolling one 1000 side dice in a range 0-999 would give you malformed result.

Conclusion, you are effectively shooting yourself in the feet, and if the engine is sensitive you might get pretty bad results. Note you'd lose also advantages of a pure integer engine.

##### Share on other sites
Quote:
 Original post by RagharConclusion, you are effectively shooting yourself in the feet, and if the engine is sensitive you might get pretty bad results. Note you'd lose also advantages of a pure integer engine.

I'm not actually rolling dice per se, but the concept is similar. However, I feel confident that a suitable approximation like the one I've devised is the right way to go. n is going to be very large, on the order of 260 million or so; k is guaranteed to be less than 72.

Given these parameters, I think I'm safe; certainly, it's a far cry from "shooting myself in the foot", especially since it's a closed-form calculation. :)

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 17
• 14
• 10
• 9
• 11
• ### Forum Statistics

• Total Topics
634094
• Total Posts
3015498
×