Search Postgresql Archives

Re: PG & random() strangeness

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 4 May 2010, Tom Lane wrote:

"Sergey E. Koposov" <math@xxxxxxxxxx> 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

Okay, the fact that they are 31bit, instead of 64 bit seems to be part of the issue, I agree. I forgot about that, and that should obviously highly increase the number of collisions. (it maybe worthwile to add the 31bittness of random to the docs, because the fact that it returns double may be confusing (as it was to me)).

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.

I think I did, since:

## select id ,count(*) from tmpx group by (id) having count(*)>1;
         id         | count
--------------------+-------
  0.519465064629912 |     2
 0.0100625408813357 |     2
  0.394671014975756 |     2
(3 rows)

and
## select id from tmpx where id > 0.51119 and id < 0.51120;
        id
-------------------
 0.511193082667887
 0.511194097343832
(2 rows)


Regards,
	S.

*******************************************************************
Sergey E. Koposov, PhD
Institute for Astronomy, University of Cambridge, UK
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math@xxxxxxxxxx

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux