help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] Random number generators and Pthreads


From: Joseph Wakeling
Subject: Re: [Help-gsl] Random number generators and Pthreads
Date: Tue, 14 Nov 2006 17:55:17 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060918)

Whoops, that earlier email was meant to go to the list as well.  Let's
get it back on track.

Martin Jansche wrote:
> On 11/12/06, Joseph Wakeling <address@hidden> wrote:
> 
>> Can you advise on appropriately seeding the rng's for different threads,
>> so as to avoid problems of correlation?
> 
> What I usually do is to have a "master seed" that's used to generate
> the seeds for the individual threads. Most of the time I just do that
> by incrementing the seed: if the first thread is seeded with 42, the
> second thread gets 43, etc. Pathological cases aside, that should be
> enough to ensure that the rng's are uncorrelated with high
> probability.

OK.  Sounds good, and allows you to keep the simplicity of having one
"real" seed that can be re-used.

> What you don't want to do is seed the rng's with random
> integers obtained from the same type of rng, because often enough the
> seed is the first value (or the value before the first one) you get
> from an rng. If you did that, you'd guarantee that the threads are
> correlated.

This is what I thought, and wanted to avoid. ;-)

> If you want to seed the threads quasi-randomly, you could
> use a very simple rng for that, e.g. a linear congruential rng since
> there are relatively few threads, as long as you use a different type
> of rng in the threads to do the real work.

Sounds like a good possibility, too.

I usually take the present time as the seed, unless I specifically want
to enter one by hand: could I just take several times?  (I admit that's
probably not a good idea on a system where taking the time takes all of
a fraction of a second:-).

> Hope this helps,

Very much.  Thank you!

    -- Joe





reply via email to

[Prev in Thread] Current Thread [Next in Thread]