Re: PG & random() strangeness - Mailing list pgsql-general

From Tom Lane
Subject Re: PG & random() strangeness
Date
Msg-id 13800.1272988972@sss.pgh.pa.us
Whole thread Raw
In response to PG & random() strangeness  ("Sergey E. Koposov" <math@sai.msu.ru>)
Responses Re: PG & random() strangeness  ("Sergey E. Koposov" <math@sai.msu.ru>)
List pgsql-general
"Sergey E. Koposov" <math@sai.msu.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

pgsql-general by date:

Previous
From: Leif Biberg Kristensen
Date:
Subject: Re: GeSHi module for Postgresql?
Next
From: Alvaro Herrera
Date:
Subject: Re: GeSHi module for Postgresql?