MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Multiple independent random number streams cannot be implemented.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg130156] Re: Multiple independent random number streams cannot be implemented.
  • From: Joe Gwinn <joegwinn at comcast.net>
  • Date: Fri, 15 Mar 2013 01:47:30 -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: <khsbbv$36f$1@smc.vnet.net>

In article <khsbbv$36f$1 at smc.vnet.net>, Roger Wilson
<rogerhw999 at gmail.com> wrote:

> Hopefully the title is enough of a red flag for someone to try to prove me
> wrong.
> 
> I want to implement two functions; lets call them f and g so that they both
> return random numbers.  For example...
> 
> f[]:=RandomReal[];
> g[]:=RandomReal[];
> 
> However I want f and g to return the same number when they're called for the
> nth time.  So the first call to f is always the same number and the first
> call to g is always the same number.
> 
> In the above case (on my machine)...
> SeedRandom[1]; {f[], g[]} gives {0.168697, 0.113119}
> 
> and of course..
> SeedRandom[1]; {g[], f[]} gives the same {0.817389, 0.11142}
> 
> Essentially I want f and g to to be independent random sources.
> 
> It is possible to localize the random number generators using BlockRandom but
> I do not see how that helps me in this case.  BlockRandom localizes the state
> of the random number generators within the block where as I want to localize them 
> into the symbol names.

SeedRandom[1] tells Mathematica to always start with a seed of 1.

The problem is that Random has internal state, so for independence you
need multiple independent sets of internal state.

So f and g need to be in different BlockRandom domains.

Joe Gwinn



  • 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 be implemented.
  • Next by thread: Re: Multiple independent random number streams cannot be implemented.