[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
rand seed
From: |
Daniel J Sebald |
Subject: |
rand seed |
Date: |
Tue, 27 Apr 2004 15:51:33 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 |
Just a few comments about the current behavior of the rand/randn
functions...
I upgraded from 2.1.46 (very confusing and peculiar "seed"/"state"
behavior) to 2.1.57. I'm glad in the documentation that it is pointed
out that rand and randn have separate generators. There was no such
documentation in 2.1.46, which I think had just a single psuedo random
number generator. Anyway, I'm trying to record the seed so that I can
reproduce simulation results at a later date. So, the idea is that one
should be able to do a
s = rand("seed")
and get the value of the seed. If one keeps a record of the answer, then
rand("seed",s);
should restore to the proper state. OK, this does seem to work as far
as I can tell. But the fact that the answer to rand("seed") is in float
means that the number will have to be saved in a file to actually
restore the value because of the potential loss of precision. All I'm
saying is that the following may lead to slight confusion to an
inexperienced user, i.e., the fact that the seed isn't restored properly:
octave:76> rand("seed")
ans = 2.6677e+167
octave:77> rand
ans = 0.64748
octave:78> rand("seed",2.6677e+167)
octave:79> rand
ans = 0.31050
Of course, the smart thing would be to always choose the seed one's-self
from the start so that such confusion couldn't arise.
A few minor things...
Here is the result of rand("seed",0):
octave:70> rand("seed",0)
octave:71> rand("seed")
ans = 2.1220e-314
I assume that the answer given is the smallest possible number. (There
is a zero in floating point 'though, isn't there?) Also,
octave:89> rand("seed",Inf)
octave:90> rand("seed")
ans = NaN
whereas
octave:92> rand("seed",NaN)
octave:93> rand("seed")
ans = 1.1125e-308
In the documentation under "help -i" for "rand/randn" is some newly
added text that doesn't seem to follow the indentation rules of all the
other documentation. That is, there are lines like:
The `rand' and `randn' functions use separate generators. This
ensures that
where the carriage return is part of the text, not part of the command
line width. The text should be indented further to the right.
There is a typo in the line (i.e., drop the "for"):
Dan
rand seed,
Daniel J Sebald <=