RE : crazy run-time fluctuations (mostly super-slow) -- a bit more data



On Sat, Oct 22, 2011 at 06:46:02PM +0100, Rupert Swarbrick wrote:
> Oliver Kullmann <O.Kullmann at swansea.ac.uk> writes:
> > Not even
> >
> > (%i1) :lisp(random-state-p random-state)
> >
> > Maxima encountered a Lisp error:
> >
> >  The variable RANDOM-STATE is unbound.
> >
> > works?
> 
> I haven't tried to do anything useful with this, but special variables
> like this in Lisp tend to have names of the form *foo*. In particular:
> 
> (%i1) :lisp (random-state-p *random-state*)
> 
> T
>

Thanks! Making progress, but not there yet:

Storing a new Lisp-random-state in a:
(%i75) :lisp (setq a (make-random-state t))
#<random-state 000000001965d000>

(%i75) :lisp (print a)
#<random-state 000000001965d000> 
#<random-state 000000001965d000>

Setting this fixed state:
(%i75) :lisp (setq *random-state* a)
#<random-state 000000001965d000>

Random number with that state:
(%i75) :lisp (random 10000)
4469
Resetting the state:
(%i75) :lisp (setq *random-state* a)
#<random-state 000000001965d000>
Again with that state:
(%i75) :lisp (random 10000)
2204

This should be 4469 again??

(%i75) :lisp (print *random-state*)

#<random-state 000000001965d000> 
#<random-state 000000001965d000>

This should have been changed now?

And another oddity:

(%i75) :lisp (make-random-state)
#<random-state 00000000196b8000>
(%i75) :lisp (make-random-state)
#<random-state 00000000196fe000>

According to http://www.ida.liu.se/imported/cltl/clm/node133.html
when called without an argument, the function make-random-state should just
return a copy of the variable *random-state*; nothing is mentioned from
changing this variable as a side-effect??

Very strange.

Hopefully somebody can explain this.

Oliver