Jump to content
  • Advertisement
Sign in to follow this  
kSquared

Standard deviation of rolling dice

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Motorherp
Have 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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by alvaro
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.

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

Share this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Raghar
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.

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. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!