comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@attbi.com>
Subject: Re: Random Number Generator Problem
Date: Fri, 25 Jul 2003 18:05:40 GMT
Date: 2003-07-25T18:05:40+00:00	[thread overview]
Message-ID: <3F217171.2080907@attbi.com> (raw)
In-Reply-To: bfrjss$7si$1@ns.omskelecom.ru

Anisimkov wrote:
 >> I'm generating a series of unsigned 64 bit integers and I get the
 >> same value for about half of the results.
 >
 >
 > I was reporting this bug to ACT.
 >
 > Do not use mod 2**64 types in random generator untill this bug would
 > be fixed. Use mod 2**63 or multiplication of two random numbers of
 > mod 2**32.

I assume you mean  Rand * 2**32 + Rand, where Rand'Modulus = 2**64 and
the range of the subtype used to instantiate the generator is any power
of two from 32 to 63.

If you use Rand * Rand, the distribution is not Uniform.  (This can
easily be seen.  The mean of Rand * Rand is 2**62, not 2**63.)

However there is another problem worth noting.  If both random values
come from the same generator, the period of the combined generator will 
be half the period of the full generator.  This is still going to be 
about 2**49 with GNAT, so it is not likely to be a big issue yet. ;-) 
But as I said, I do have it on my to do list to create a generator for 
types with a range of > 2**48 that has a period greater than 2**64.

-- 

                                                        Robert I. Eachus

�In an ally, considerations of house, clan, planet, race are
insignificant beside two prime questions, which are: 1. Can he shoot? 2.
Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and
Steve Miller.




      reply	other threads:[~2003-07-25 18:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-25 14:34 Random Number Generator Problem Brien
2003-07-25 15:34 ` Robert I. Eachus
2003-07-28 13:14   ` Brien
2003-07-25 17:06 ` Anisimkov
2003-07-25 18:05   ` Robert I. Eachus [this message]
replies disabled

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