Re: rand function question



Joachim wrote:
Peter Perkins <Peter.PerkinsRemoveThis@xxxxxxxxxxxxx> wrote
Also, the period of the generator is _very_ long (2^19936
or thereabouts), so
while you might get repeated values in your lifetime, you
will not see the
sequence repeat any time in the foreseeable future.

Well, on my Matlab (R2007a/Linux x86), every time I fire up
Matlab and enter (as first command)

format long; rand

I get

ans =
0.814723686393179

I'm guessing you know the reason for this, but just in case:

>> help rand

[snip]

The sequence of numbers produced by RAND is determined by the internal
state of the generator. Setting the generator to the same fixed state
allows computations to be repeated. Setting the generator to different
states leads to unique computations, however, it does not improve any
statistical properties. Since MATLAB resets the state at start-up, RAND
will generate the same sequence of numbers in each session unless the
state is changed.
.



Relevant Pages

  • Re: Weird problem with fmincon on 2008b
    ... I am simulating a data generating process hence the use of randn. ... Everything goes well until I open up a second instance of Matlab 2008b (in ... Start one session of MATLAB and perform some operations involving RAND, ... pseudorandom number generator in the two sessions are not in the same state. ...
    (comp.soft-sys.matlab)
  • Re: weird thing using rand
    ... The sequence of numbers produced by RAND is determined by the internal ... Setting the generator to the same fixed state ... states leads to unique computations, however, it does not improve any ...
    (comp.soft-sys.matlab)
  • Re: A concern about the Matlab implementation of the Mersenne Twister RNG.
    ... MATLAB's "basic" data class is double precision, so rand generates double ... much more comforting if Matlab was giving the same string as the ... On Mar 8, 10:48 am, Peter Perkins ...
    (comp.soft-sys.matlab)
  • Re: Random number generator
    ... > I wanted to find out if any of the pseudo-random number generator ... > functions in MATLAB can be modified to solve ... > I don't care about the distribution of the random numbers as long as ... Knowing that rand outputs numbers between 0 and 1, ...
    (comp.soft-sys.matlab)
  • Resetting the state of Rand randomly at start up
    ... I was using rand to simulate a price series, ... Because MATLAB resets the rand state at startup, ... What this does is automatically saves your random state ...
    (comp.soft-sys.matlab)