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, 20 Mar 2007 17:08:32 +0000
User-agent: Thunderbird 1.5.0.10 (X11/20070306)

Ages ago I asked the list about using the random number generators with
Pthreads.  Some of the discussion follows this mail.

The reason why I was interested in Pthreads was because I often have to
do simulations which perform many runs of a given situation so as to
average over different initial conditions.

Of course, in many cases it's fine to do this in a serial program and I
often do.  I was wondering about the scenario outlined in the discussion
below, of using one random number generator (or an incremented sequence)
to generate seeds for the rng's used in the threads.  Would it be worth
doing this in a _serial_ program, generating different seeds for the
individual runs?  Or is it better to stick with one rng for a serial
program?

Thanks in advance for any suggestions,

    -- Joe


> 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.





reply via email to

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