[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sampling from two instances of a random number generator
From: |
Francesco Potorti` |
Subject: |
Re: sampling from two instances of a random number generator |
Date: |
Sun, 25 May 2008 22:46:16 +0200 |
>I need to sample from several instances of a random number generator
>in the same program. Apparently, Octave does not let me do it. It
>seems as though that "rand" has only one global state. The best advice
>from the manual is to save/restore rand state with
> v = rand("state")
> rand("state", v)
>
>Since I have to draw only one number at a time from each RNG millions
>of time this can quickly become a nuisance. Also, it is plain ugly!
Why? You just define a function that takes the generator identifier (a
number) as its only argument and returns a fresh random number from that
generator. The function contains a persistent matrix (or cell array)
with the states of all your generators. You start with a random matrix,
or a fixed matrix.
>Octave is object oriented, right? Why not to have a RNG constructor
>rng1= RNGuniform(seed)
>...
>sample= rng1.get()
With the sulution I suggest above it would be
sample=multrng(n)
--
Francesco Potortì (ricercatore) Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR Fax: +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa Email: address@hidden
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it/
- Re: sampling from two instances of a random number generator, (continued)
- Re: sampling from two instances of a random number generator, Ben Abbott, 2008/05/24
- Re: sampling from two instances of a random number generator, Jaroslav Hajek, 2008/05/25
- Re: sampling from two instances of a random number generator, Leo Razoumov, 2008/05/25
- Re: sampling from two instances of a random number generator, Leo Razoumov, 2008/05/25
- Re: sampling from two instances of a random number generator, Søren Hauberg, 2008/05/26
- Re: sampling from two instances of a random number generator, Leo Razoumov, 2008/05/27
- Re: sampling from two instances of a random number generator, David Bateman, 2008/05/27
Re: sampling from two instances of a random number generator,
Francesco Potorti` <=