help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bad random numbers


From: Mike Miller
Subject: Re: bad random numbers
Date: Tue, 13 Jul 1999 20:28:14 -0500 (CDT)

Not everyone is getting it.  Look at these two lines:

echo 'rand(3)' | octave -q
echo 'rand("seed",time);rand(3)' | octave -q

Question:  If rand gets its seed from the clock when octave starts, then
why does the first command line above give aberrant results while the
second command works beautifully?

Answer: There is an error in the generation of the initial seed.

Am I wrong?

I don't know C and can't fix it, but it should be easy for a C programmer
to compare rand.cc and randinit.m and figure out what's wrong in rand.cc.

MATLAB doesn't promise to generate a seed from the system clock at
startup.  It would be nice if they did generate the seed, but they don't
do it, so I can't criticize their method of seed generation.

Mike

-- 
Michael B. Miller
University of Missouri--Columbia
http://taxa.psyc.missouri.edu/~mbmiller/



---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]