On Sun, 15 Jun 2014, J-P. Rosen wrote: > Le 15/06/2014 20:54, Stefan.Lucks@uni-weimar.de a écrit : >> The alternative is to (2n) instantiate a single random generator (I've >> forgotten the package name, but it is not A.N.Discrete_Random), which >> just generates a Float F_Rand between 0 and 1. Then set R_I := >> Truncate(1 + F_Rand * (50-I)). > This is not equivalent. I don't remember the details, but in the making > of Ada 95 there was a furious discussion between numericists about > whether it was possible to make a discrete random generator given a > floating point random generator. > > After megabytes of E-mail discussion, they concluded that NO, it was not > possible, and therefore that Ada should have both. I am not aware of that discussion, but mathematically, given a uniformly distributed real number F between 0.0 and 1.0, one can get a uniformly distributed discrete D between Low and high: D := Truncate(Low + F * (High-Low + 1)). I guess, the issue that has been raised in that discussion that if F is of type float or even double-float, it has a mantissa of limited size, and then the distribution of D would significantly deviate from the uniform distribution if High-Low happens to be large. In the current case, however, High-Low < 50, so the solution using the uniformly distributed float should work properly. If D would significantly deviate from the uniform distribution, then so would F. ------ I love the taste of Cryptanalysis in the morning! ------ --Stefan.Lucks (at) uni-weimar.de, Bauhaus-Universität Weimar, Germany--