comp.lang.ada
 help / color / mirror / Atom feed
From: Andreas Almroth <andreas.almroth@uppsala.mail.telia.com>
Subject: Strange results with random numbers with Gnat 3.10
Date: 1998/01/07
Date: 1998-01-07T00:00:00+00:00	[thread overview]
Message-ID: <34B3F618.DC9@uppsala.mail.telia.com> (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... :-)




             reply	other threads:[~1998-01-07  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-07  0:00 Andreas Almroth [this message]
1998-01-07  0:00 ` Strange results with random numbers with Gnat 3.10 Mats Weber
1998-01-08  0:00   ` Andreas Almroth
1998-01-08  0:00     ` Mats Weber
1998-01-08  0:00 ` Philip Brashear
replies disabled

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