comp.lang.ada
 help / color / mirror / Atom feed
* Strange results with random numbers with Gnat 3.10
@ 1998-01-07  0:00 Andreas Almroth
  1998-01-07  0:00 ` Mats Weber
  1998-01-08  0:00 ` Philip Brashear
  0 siblings, 2 replies; 5+ messages in thread
From: Andreas Almroth @ 1998-01-07  0:00 UTC (permalink / raw)



Hi folks,
I was wandering through the excellent online RM Ada95 at
www.adahome.com and read about the random number facility
(A.5.2).
I compiled and ran the dice example program, and everything
seemed OK. But just as a curiousity I wanted to see how the
numbers were actually distributed, so I changed the program
to loop one million times, and then present the frequency.
To my big suprise this was the result;

Number  Frequency
=================
  1        249594
  2        167104
  3        166985
  4        166687
  5        166621
  6         83009

A bit odd distribution, if I may say so... Is this a feature
of Gnat, or?

The reference manual clearly states that;

" 		Implementation Requirements
(41)
	A sufficiently long sequence of random numbers obtained by
successive calls to Random is approximately uniformly distributed over
the range of the result subtype."

So, the result should be different...

Any comments, or I'm making the wrong conclusions?

Of course, one could use 2..5 and skip the min and max values, but
why should I do that, if the Ada95 language enviroment should handle it?

Regards,
         Andreas Almroth
-- 
============================================================
A3CE, Advanced Computer Engineering
System Integration Consultants
Phone: +46-18-100 790
============================================================
Any opinions expressed in this letter, are mine, and the 
company's, because I own it... :-)




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1998-01-08  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-07  0:00 Strange results with random numbers with Gnat 3.10 Andreas Almroth
1998-01-07  0:00 ` Mats Weber
1998-01-08  0:00   ` Andreas Almroth
1998-01-08  0:00     ` Mats Weber
1998-01-08  0:00 ` Philip Brashear

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox