Hacker News new | ask | show | jobs
by prionassembly 1533 days ago
The source of disagreement is: his code generates floating point approximations of uniformly-distributed real values in [0,1]; not random floats greater than 0 and smaller than 1.

This distinction has little to do with the subtlety of floats. You can e.g. generate numbers up to 100 with

- 5d20 (5 dice of 20 sides),

- 20d5 or even

- 16d6+1d4.

[Edit: the point of this exercise: these are different representations of the numbers up to 100.]

But even assuming each die with D sides has equiprobable results with prob 1/D, these choices don't have the same probability distribution. To convince yourself of this, compare 1d12 (the probability of getting 1 is 1/12) with 2d6 (the probability of getting 1 is 0).