Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13867

Re: Multiple independent random number streams cannot be implemented.

From David Bailey <dave@removedbailey.co.uk>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Multiple independent random number streams cannot be implemented.
Date 2013-03-17 23:48 +0000
Message-ID <ki5ko5$e7e$1@smc.vnet.net> (permalink)
References <20130314111450.25C5269D8@smc.vnet.net> <khucj3$8c$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Multiple independent random number streams cannot be implemented. Sseziwa Mukasa <mukasa@gmail.com> - 2013-03-15 05:46 +0000
  Re: Multiple independent random number streams cannot be implemented. David Bailey <dave@removedbailey.co.uk> - 2013-03-17 23:48 +0000
    Re: Multiple independent random number streams cannot be implemented. Vince Virgilio <blueschi@gmail.com> - 2013-03-18 09:34 +0000
      Re: Multiple independent random number streams cannot be implemented. David Bailey <dave@removedbailey.co.uk> - 2013-03-19 04:05 +0000
  Re: Multiple independent random number streams cannot be implemented. Vince Virgilio <blueschi@gmail.com> - 2013-03-19 05:51 +0000

csiph-web