Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: recovering the jth state of the random number generator
Date: Tue, 9 Sep 2008 16:14:02 +0000 (UTC)
Organization: Johns Hopkins School of Med
Lines: 35
Message-ID: <ga67ca$pln$1@fred.mathworks.com>
References: <g9sh0d$pra$1@fred.mathworks.com> <MCkwk.148759$nD.29247@pd7urf1no> <g9une6$lfl$1@fred.mathworks.com> <ga61ag$1lt$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1220976842 26295 172.30.248.38 (9 Sep 2008 16:14:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 9 Sep 2008 16:14:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1442513
Xref: news.mathworks.com comp.soft-sys.matlab:489397



Hi Peter,

i studied a little into it, and begin to understand how the random number generator actually works.  Since it is not simply a f(x), with x being the successive states, one cannot recover the jth state after a given beginning seed except by running the actual generator with the correct seed.  Since my application is to produce a succesion of matrices (which will become images after a lookup table application) that are random with respect to each other, but  easy to recover to be able to run reverse correlations of stimulus responses on the given stimulus
  rand('state', myseed);
  for i  = 1:framenumber
  noisematrix = rand (side,side)
  end


i have take the typical approach of the molecular biologist.
I ran the above loop offline, and stored all the frames.  Since i need a grayscale lookup table (0-255), that fits in a uint8, the whole thing is under 200 Mb.  Then i can reverse correlate at ease, on the saved file.

I have to say everybody that answered to my quest was very helpful, and i will be back for sure with more simpleminded questions.

Tudor


Peter Perkins <Peter.PerkinsRemoveThis@mathworks.com> wrote in message <ga61ag$1lt$1@fred.mathworks.com>...
> Tudor wrote:
> 
> > How about if i 'seed' the rand function at each iteration ?:
> > 
> > for i = 1:90000
> > 
> > rand ('state', i);
> > randmonoisematrix = rand (45, 45);
> > 
> > end
> 
> Tudor, I recommend not doing that.  Some people try to do that each time they generate a single value, and that's definitely a bad idea, because the statistical properties of the generator are completely destroyed.  Reseeding each time you generate a 45x45 matrix isn't quite as bad, but still ...
> 
> What you're looking for is often called substreams.
> 
> If you have access to the MATLAB prerelease, I recommend looking at that.