[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bad random numbers
From: |
John Judge |
Subject: |
Re: bad random numbers |
Date: |
Wed, 14 Jul 1999 13:30:53 +1000 (EST) |
Mike,
On Tue, 13 Jul 1999, Mike Miller wrote:
> 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?
>
The difference appears to be the value used in the seeding. The first
command uses the seed calculated in the code fragment shown in the
earlier email which is based on the integer value of epoch seconds. The
second command uses a seed based on the builtin function time which
returns a double based on epoch seconds and microseconds. Using 2.0.14
I get:
octave:9> for i = 1:10
> printf("%f\n", time);
> endfor
931922099.301045
931922099.301411
931922099.301682
931922099.301951
931922099.302221
931922099.302490
931922099.302763
931922099.303038
931922099.303316
931922099.303587
I think you will find the undesirable result if you change the second
command to:
echo 'rand("seed",floor(time));rand(3)' | octave -q
John Judge
Research Manager email : address@hidden
TITR phone : +61 42 21 4442
University of Wollongong fax : +61 42 21 3277
---------------------------------------------------------------------
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
---------------------------------------------------------------------
- Re: bad random numbers, (continued)
Re: bad random numbers, Mike Miller, 1999/07/13
- Re: bad random numbers, John W. Eaton, 1999/07/13
- Re: bad random numbers, Mike Miller, 1999/07/13
- Re: bad random numbers, John W. Eaton, 1999/07/13
- Re: bad random numbers, A+A Adler, 1999/07/13
- Re: bad random numbers, Mike Miller, 1999/07/13
- Re: bad random numbers,
John Judge <=
- Re: bad random numbers, lash, 1999/07/13
- Re: bad random numbers, Mike Miller, 1999/07/14
- Re: bad random numbers, lash, 1999/07/14
- Re: bad random numbers, Jim Van Zandt, 1999/07/14
- Re: bad random numbers, John W. Eaton, 1999/07/14
Re: bad random numbers, Thomas Walter, 1999/07/14
Re: bad random numbers, Eric Ortega, 1999/07/15
Re: bad random numbers, Jim Van Zandt, 1999/07/14
Re: bad random numbers, John Smith, 1999/07/14
Re: bad random numbers, heberf, 1999/07/13