Re: Random not so random

From: "Dann Corbit" <DCorbit(at)connx(dot)com>
To: "Dann Corbit" <DCorbit(at)connx(dot)com>, <pgsql-general(at)postgresql(dot)org>
Cc: <stimits(at)comcast(dot)net>
Subject: Re: Random not so random
Date: 2004-10-05 16:50:53
Message-ID: D425483C2C5C9F49B5B7A41F89441547055525@postal.corporate.connx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Here is a tarball for MT:
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.t
gz

It has a BSD license. What could be better?

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Dann Corbit
> Sent: Tuesday, October 05, 2004 9:34 AM
> To: pgsql-general(at)postgresql(dot)org
> Cc: stimits(at)comcast(dot)net
> Subject: Re: [GENERAL] Random not so random
>
>
> A better way would be to seed a Mersenne Twister PRNG at
> server startup time and then use the same generator for all
> subsequent calls.
> http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
>
> The period is exceptionally long, and it has many excellent
> properties.
>
> > -----Original Message-----
> > From: pgsql-general-owner(at)postgresql(dot)org
> > [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of D. Stimits
> > Sent: Monday, October 04, 2004 7:23 AM
> > Cc: pgsql-general(at)postgresql(dot)org
> > Subject: Re: [GENERAL] Random not so random
> >
> >
> > Tom Lane wrote:
> > > "Arnau Rebassa" <arebassa(at)hotmail(dot)com> writes:
> > >
> > >> I'm using a debian linux as OS with a 2.4 kernel running on it.
> > >
> > >
> > >>>Incidentally, are you reconnecting every time or is it
> > that multiple
> > >>>calls
> > >>>in a single session are returning the same record?
> > >
> > >
> > >> I'm reconnecting each time I want to retrieve a message.
> > >
> > >
> > > Hmm. postmaster.c does this during startup of each
> backend process:
> > >
> > > gettimeofday(&now, &tz);
> > > srandom((unsigned int) now.tv_usec);
> >
> > If it uses the same seed from the connection, then all
> > randoms within a
> > connect that has not reconnected will use the same seed.
> > Which means the
> > same sequence will be generated each time, which is why it is
> > pseudo-random and not random. For it to be random not just
> the first
> > call of a new connection, but among all calls of new connection, it
> > would have to seed it based on time at the moment of query
> and not at
> > the moment of connect. A pseudo-random generator using the
> same seed
> > will generate the same sequence.
> >
> > D. Stimits, stimits AT comcast DOT net
> >
> >
> > ---------------------------(end of
> > broadcast)---------------------------
> > TIP 8: explain analyze is your friend
> >
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so
> that your
> message can get through to the mailing list cleanly
>

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Cohen 2004-10-05 17:00:15 problem with pg_restore
Previous Message Tom Lane 2004-10-05 16:45:33 Re: Set locale per query?