On Mon, 16 Jun 2014, J-P. Rosen wrote: >> 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 think it all depends on the definition of "uniformly distributed". If > it is uniformly distributed among all representable floating point > numbers (which you get if you take an integer random number and > unchecked-convert it to Float), you'll get many more values below 0.5 > than above (since the range 0.5..1.0 is represented with only one value > of the exponent). Well, do you think the Annotated Reference Manual needs a clarification? It explicitely tells A sufficiently long sequence of random numbers obtained by successive calls to Random is approximately uniformly distributed over the range of the result subtype. From my point of view, "uniformly distributed over the range of the result subtype" would seem to imply values > 0.5 to be as often as values < 0.5. In fact, I would claim that any random generator, choosing floats between 0.0 and 1.0 with a significant bias towards 0.0 or 1.0 would be plain stupid and worse than useless, and a standard which allows that, would need urgent repair! Fortunately, my Ada compiler (gnat) is not such stupid and behaves as I had expected: with Ada.Text_IO, Ada.Numerics.Float_Random, Ada.Command_Line; procedure Test_Rnd is package ANFR renames Ada.Numerics.Float_Random; Gen: ANFR.Generator; High: Natural := 0; Sample_Size: constant Natural := Natural'Value(Ada.Command_Line.Argument(1)); begin ANFR.Reset(Gen); for I in 1 .. Sample_Size loop if ANFR.Random(Gen) > 0.5 then High := High + 1; end if; end loop; Ada.Text_IO.Put_Line(Integer'Image(High) &" /"& Integer'Image(Sample_Size)); end Test_Rnd; Compiling and running the above program indicates an even distribution of values > 0.5 and <= 0.5 (i.e., there is no statistically significant bias): $ ./test_rnd 100000000 49999482 / 100000000 $ ./test_rnd 1000000000 499991845 / 1000000000 Note that the results are biased towards 0.0, but the bias is statistically insignificant. (It would be statistically strange, indeed, if *exactly* half of the random values would be below 0.5, and the other half would be above.) So long ------ I love the taste of Cryptanalysis in the morning! ------ --Stefan.Lucks (at) uni-weimar.de, Bauhaus-Universität Weimar, Germany--