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



Hi Bill,

> ====================================================================
> 
> As described, LIMIT is a required argument and RANDOM-STATE is an
> optional argument.  The error message in your post said "Wrong number of
> arguments passed to function RANDOM.", which could have been more
> explicit by mentioning the number of arguments that are required.
> 
> Here is a transcript of a session in SBCL, a free implementation of
> Common Lisp:
>

I think I understand (basically) the syntax now -- thanks!

However, the semantics I still don't understand: The original
problem was to make a Maxima-function, which uses the Lisp random-function,
reproducible, that is, perform the same call under the same circumstances
at least twice, so that time and memory consumption for the two calls
can be measured.

However, with each invocation of :lisp seems to start a fresh environment,
unrelated to the invocation before, so that between two Maxima-calls apparently
no relation can be established between the calls of random??:

(%i447) :lisp (setq ss *random-state*)
#<random-state 000000000143b000>
(%i447) :lisp (setq ss2 *random-state*)
#<random-state 000000000143b000>
(%i447) :lisp (equal ss ss2)
T
(%i447) :lisp (random 1000 ss)
808
(%i447) :lisp (random 1000 ss2)
57
(%i447) :lisp (equal ss ss2)
T
 
Either ss is not equal ss2, or random has hidden parameters ---
but the point of the second parameter should be exactly to exclude
hidden parameters?

If I understand the previous example correctly (that with the syntax error),
then one had some control over function random within a single call of :lisp
(however also in that example I don't understand the semantics), but as
the above seems to show, between different invocations of :lisp something
changes??

Perhaps one shouldn't consider variable *random-state* directly, only
via make-random-state? However also then everything breaks:

(%i447) :lisp (setq ss (make-random-state t))
#<random-state 0000000027509000>
(%i447) :lisp (setq ss2 (make-random-state ss))
#<random-state 00000000272a3000>
(%i447) :lisp (equal ss ss2)
NIL

The documentation says make-random-state when called with a state creates
a copy. But apparently it doesn't do so?
Perhaps variables need to be declared before?

) :lisp (defvar *ss* (make-random-state t))
*SS*
(%i447) :lisp (defvar *ss2* (make-random-state *ss*))
*SS2*
(%i447) :lisp (equal *ss* *ss2*)
NIL

Or defining a constant?

(%i447) :lisp (defconstant ss (make-random-state t))
SS
(%i447) :lisp (defconstant ss2 (make-random-state ss))
SS2
(%i447) :lisp (equal ss ss2)
NIL

It seems the Lisp binding-and-interpretation mechanism is undefeatable ---
no chance to get it to do some reasonable ...

Perhaps the fundamental problem is that the Lisp-documentations you find
on the Internet do not consider the two levels we have in Maxima:
the Maxima outer level and the Lisp inner level??

Sigh.

Oliver