Skip site navigation (1) Skip section navigation (2)

win32 random number generator

From: "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com>
To: <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: win32 random number generator
Date: 2005-08-22 19:59:57
Message-ID: 6EE64EF3AB31D5448D0007DD34EEB3417DD16D@Herge.rcsinc.local (view raw or flat)
Thread:
Lists: pgsql-hackers-win32
The windows random number of generator (a port of lrand48 in random.c)
seems a little weak.  It seems to only offer about 16 bits of precision.
Maybe there is a bug in the implementation?

Merlin

observe:
esp=# select count(*)  from (select distinct random() from
generate_series(1,1000000)) q;
 count
-------
 65559
(1 row)

esp=# select count(*)  from (select distinct random() from
generate_series(1,1000000)) q;
 count
-------
 65558
(1 row)

esp=# select count(*)  from (select distinct random() from
generate_series(1,1000000)) q;
 count
-------
 65572
(1 row)

esp=# select min(r), max(r), avg(r) from (select random() as r from
generate_series(1,1000000)) q;
         min          |        max        |        avg
----------------------+-------------------+-------------------
 4.6566128752458e-010 | 0.999984742142253 | 0.499985154491819
(1 row)

esp=# select min(r), max(r), avg(r) from (select random() as r from
generate_series(1,1000000)) q;
         min          |        max        |       avg
----------------------+-------------------+------------------
 4.6566128752458e-010 | 0.999984742142253 | 0.50079921773987
(1 row)

esp=#
esp=# select min(r), max(r), avg(r) from (select random() as r from
generate_series(1,1000000)) q;
         min          |        max        |        avg
----------------------+-------------------+-------------------
 4.6566128752458e-010 | 0.999984742142253 | 0.499613384426336
(1 row)

Responses

pgsql-hackers-win32 by date

Next:From: Tom LaneDate: 2005-08-22 20:47:46
Subject: Re: win32 random number generator
Previous:From: Dave PageDate: 2005-08-19 18:36:25
Subject: Re: [PATCHES] PostgreSQL 8.0.3 and Ipv6

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group