Re: Still wondering about random numbers...

From: gateley(at)jriver(dot)com
To: Joe Conway <joseph(dot)conway(at)home(dot)com>
Cc: "Dr(dot) Evil" <drevil(at)sidereal(dot)kz>, pgsql-general(at)postgresql(dot)org
Subject: Re: Still wondering about random numbers...
Date: 2001-08-07 16:41:36
Message-ID: 3B701A40.B0EC1685@jriver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

Joe Conway wrote:
>
> > I am running on OpenBSD and Linux, both of which have
> > cryptographic-quality RNGs built in. When I call RANDOM() in PG, do I
> > get the old C library random numbers, which are not very random, or do
> > I get high-quality random numbers from the crypto-RNG that's built in?
> > Any sugestions for getting high-quality random numbers?
>
> Looking through the source, I find:
> result = ((double) random()) / ((double) MAX_RANDOM_VALUE);

The random() function returns better (good?)
random numbers. The rand() function returns poor
random numbers. random() also depends on how
much state it is initialized with (and may or may
not be based on /dev/random, I don't know).

j

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2001-08-07 16:53:15 Re: Still wondering about random numbers...
Previous Message Thomas Lockhart 2001-08-07 16:36:23 Re: Still wondering about random numbers...

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2001-08-07 16:48:14 Re: Re: Fuzzy matching
Previous Message Thomas Lockhart 2001-08-07 16:36:23 Re: Still wondering about random numbers...