Re: Multiple independent random number streams cannot be implemented.

• To: mathgroup at smc.vnet.net
• Subject: [mg130171] Re: Multiple independent random number streams cannot be implemented.
• From: David Bailey <dave at removedbailey.co.uk>
• Date: Sun, 17 Mar 2013 03:08:28 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-newout@smc.vnet.net
• Delivered-to: mathgroup-newsend@smc.vnet.net
• References: <20130314111450.25C5269D8@smc.vnet.net> <khucj3\$8c\$1@smc.vnet.net>

```On 15/03/2013 05:46, Sseziwa Mukasa wrote:
> You are asking for the opposite of independent random variables.
>
> I can think of a couple of solutions to your problem.  If you know how
> many samples you're going to take you can initialize a vector and have f
> &  g remember where they are in the vector.
>
There is a variable called \$RandomState, which is poorly documented, but
seems (from a quick test) to hold enough information to restore the
random number generator to any position. Thus, any process can generate
its own random sequence:

fstate = 0;
f[] := Block[{\$RandomState = \$RandomState, tmp},
If[fstate ===0,
SeedRandom["The f function"];
fstate = \$RandomState;
];
\$RandomState = fstate;
tmp = Random[];
fstate = \$RandomState;
tmp
];
gstate = 0;
g[] := Block[{\$RandomState = \$RandomState},
If[gstate ===0,
SeedRandom["The g function"];
gstate = \$RandomState;
];
\$RandomState = gstate;
tmp = Random[];
gstate = \$RandomState;
tmp
]

Unfortunately, the documentation at 9.0 deprecates the use of
\$RandomState - stating that it is superseded by BlockRandom - but
clearly \$RandomState can solve problems which BlockRandom cannot.

David Bailey
http://www.dbaileyconsultancy.co.uk

```

• Prev by Date: Re: Visible mesh edges in PDF output of 3D graphic
• Next by Date: Re: Visible mesh edges in PDF output of 3D graphic
• Previous by thread: Re: Multiple independent random number streams cannot
• Next by thread: Re: Multiple independent random number streams cannot be implemented.