help-octave
[Top][All Lists]
Advanced

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

Re: bad random numbers


From: Thomas Walter
Subject: Re: bad random numbers
Date: Wed, 14 Jul 1999 10:14:13 +0200

>>>>> "Mike" == Mike Miller <address@hidden> writes:

Hello,
has anybody tried the random generator I submitted some weeks ago?
It is an interface to the GSL default random generator written in C++
to compile to an .oct-file.
The version I submitted has only one problem, it uses always the same
seed if started (it is read from an environment variable).
This means if you call it from a script you always get the same
numbers.
Currently I investigate some time to add an automatic seeding with the
'time()' function.  The first checks look fine, I think.  After
seeding you get always different numbers.
I think this is because this random generator has a much larger period
length than the random generator from the fortran library.

Hints are welcome.

Site note:
It is no problem for me to change the code written in C (C++ if it is not
to tricky/complicate), but with fortran i loose.

Bye
Thomas

    Mike> Not everyone is getting it.  Look at these two lines:
    Mike> echo 'rand(3)' | octave -q
    Mike> echo 'rand("seed",time);rand(3)' | octave -q

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

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

    Mike> Am I wrong?

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

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

    Mike> Mike

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



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



-- 
Platzangst:
Der dauerhafte Zustand eines Luftballons.

----------------------------------------------
Dipl. Phys. Thomas Walter
Inst. f. Physiklische Chemie II
Egerlandstr. 3                          Tel.: ++9131-85 27326 / 27330
91058 Erlangen, Germany                 email: address@hidden



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