Re: PG & random() strangeness

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PG & random() strangeness
Date: 2010-05-04 16:02:52
Message-ID: 13800.1272988972@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Sergey E. Koposov" <math(at)sai(dot)msu(dot)ru> writes:
> So among 10^5 random numbers there are already 3 collisions. Which doesn't
> seem right for the function which generate randoms of double precision

The underlying random() function only generates 31-bit integers, so
collisions aren't as improbable as they might seem. See
http://en.wikipedia.org/wiki/Birthday_paradox

> It is also interesting that in the table tmpx1 (if I actually output the
> values using select id from tmpx1) I do not see equal numbers at all but I see
> for example two values which are close to each other:
> 0.511193082667887
> 0.511194097343832

> First it seems strange that they have been merged into one group by "groupby".

They aren't; or at least you've not provided any evidence that they were.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2010-05-04 16:02:56 Re: GeSHi module for Postgresql?
Previous Message Leif Biberg Kristensen 2010-05-04 15:41:56 Re: GeSHi module for Postgresql?