help-octave
[Top][All Lists]
Advanced

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

Re: bad random numbers


From: Timothy H. Keitt
Subject: Re: bad random numbers
Date: Tue, 13 Jul 1999 15:18:35 -0700

If you set the seed from the time, then the first number *must be* some
function of the value returned by time().  These things are deterministic,
hence the name pseudo-random.  A friend of mine who is writing a book on
Monte Carlo methods uses the "generator warming" approach I suggested.  I've
also seen people use the system rand() or drand48() function to generate a
seed for the working generator, first seeding one of those using time().

Tim

Mike Miller wrote:

> On Tue, 13 Jul 1999, Timothy H. Keitt wrote:
>
> > Its probably a good idea to "warm up" the generator by discarding the
> > first 1000 or so numbers.  I would add this to the seed routine.
>
> That isn't the way to go.  We just need to get one good seed to start out.
> The way it runs now, I think it isn't generating the first number from a
> seed, but by some function of the time.  We need to look at the code.
>
> By the way, the following command does *not* have the problems we were
> seeing when we didn't use randinit:
>
> echo "randinit; rand (3)" | octave -qf
>
> Somehow, left to its own devices, rand makes a bad first number when there
> is no seed already set.  I think rand is using time to make a first
> number, not to make an initial seed.
>
> Mike
>
> --
> Michael B. Miller, M.S., Ph.D., M.P.E.
> Department of Psychology
> 210 McAlester Hall
> University of Missouri--Columbia
> Columbia, MO 65211
>  Phone: (573) 882-5671
>    Fax: (573) 882-7710
> e-mail: address@hidden
>    web: 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
> ---------------------------------------------------------------------



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