help-octave
[Top][All Lists]
Advanced

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

Re: bad random numbers


From: Jim Van Zandt
Subject: Re: bad random numbers
Date: Tue, 13 Jul 1999 08:52:01 -0400

Mike -

I tried this, to extract the 1,1 element of several matrices in a row:
    for x in `seq 100`; do ./makerand|awk 'NR==3{print $1; exit}'>>values;
    done

This took about 10 seconds to run on my machine.  The output starts
like this:
    vanzandt-pc:/tmp$ head -15 values
    0.61386
    0.61386
    0.61386
    0.61386
    0.61386
    0.61386
    0.61386
    0.61386
    0.61386
    0.61386
    0.61386
    0.61386
    0.69625
    0.69625
    0.69625

The number continued to grow in stairstep fashion until it wrapped
around to zero.  Apparently, the random number generator is
initialized from the system clock, and advances by 0.082390 each
second.

I suggest that the random number generator should be initialized using
the microseconds field of the struct returned by gettimeofday(), if
available (so it's more likely to start differently from one run to
the next), and that one number should be discarded after
initialization (to destroy the correlation between one run and the
next).

                - Jim Van Zandt



---------------------------------------------------------------------
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]