- ...you.
- On a UNIX system you can use the function
load-data
to
load the tutorial data. After starting up XLISP-STAT enter the expression
(load-data "tutorial")
, followed by a
return
.
- ...are
- The file
xlisp.help
is optional. It may be
replaced by a reduced file
xlisp.help.small
or it may be
omitted entirely. If it is not present interactive help will not be
available.
- ...this
- On a Macintosh with limited memory a dialog
warning about memory restrictions may be appear at this point. On a
Mac II it takes about a minute to load these files; on a Mac Plus or
an SE it takes about 3.5 minutes.
- ...printing.
- It is possible to
make a finer distinction. The
reader
takes a string of
characters from the listener and converts it into an expression. The
evaluator
evaluates the expression and the
printer
converts the result into another string of characters for the listener
to print. For simplicity I will use
evaluator
to describe the
combination of these functions.
- ...form
-
def
acts like a special form, rather than a function,
since its first argument is not evaluated (otherwise you would have to
quote the symbol). Technically
def
is a macro, not a special
form, but I will not worry about this distinction in this tutorial.
def
is closely related to the standard Lisp special forms
setf
and
setq
. The advantage of using
def
is that
it adds your variable name to a list of
def
'ed variables that
you can retrieve using the function
variables
. If you use
setf
or
setq
there is no easy way to find variables
you have defined, as opposed to ones that are predefined.
def
always affects top level symbol bindings, not local bindings. It can
not be used in function definitions to change local bindings.
- ...electric-heat.
- On UNIX systems use the function
load-data
. For example, evaluating the expression
(load-data "car-prices")
should load the file
car-prices.lsp
.
- ...time.
- As an aside, a Lisp symbol can be thought of as a ``thing''
with four cells. These cells contain the symbol's print name, its
value, its function definition, and its property list. Lisp symbols
are thus much more like physical entities than variable identifiers in
FORTRAN or C.
- ...returned.
- The generator used is Marsaglia's portable generator from
the
Core Math Libraries
distributed by the National Bureau of
Standards. A state object is a vector containing the state information of
the generator. ``Random'' reseeding occurs off the system clock.
- ...XLISP-STAT
- The on line help file may not be available on a single disk
version that includes a system file. Alternatively, there may be a
small help file available that does not contain documentation for all
functions.
- ...arguments.
- This process of applying a function elementwise
to its arguments is called
mapping
.
- ...expects
- The notation used corresponds to the specification of the argument
lists in Lisp function definitions. See Section
8
for more
information on defining functions.
- ...keyword
- Note that the keyword
:title
has not been quoted.
Keyword symbols
, symbols starting with a colon, are somewhat
special. When a keyword symbol is created its value is set to itself.
Thus a keyword symbol effectively evaluates to itself and does not
need to be quoted.
- ...pi
- Actually
pi
represents a constant, produced with
defconst
. Its value can't be changed
by simple assignment.
- ...out
-
To support these features the listener checks the current expression
each time you type a
return
to see if it has a complete
expression. If so, the expression is passed to the reader and the
evaluator. If not, you can continue typing. There are some heuristics
involved here, and an expression with lots of quotes and comments may
cause trouble, but it seems to work. Redefining the read table in
major ways may not work as you might expect since some knowledge of
standard Lisp syntax is built in to the listener.
- ...type
- I have used a quoted list
'(purchases precipitation)
in this expression to pass the list of symbols to the
savevar
function. A longer alternative would be the expression
(list
'purchases 'precipitation).
- ...scatterplots
- According
to Stuetzle [
16
] the idea to link several plots was first
suggested by McDonald [
12
].
- ...symbol
- The result returned by
plot-points
is printed something
like
#<Object: 2010278, prototype = SCATTERPLOT-PROTO>
. This
is not the value returned by the function, just its printed
representation . There are several other data types that are printed
this way;
file streams
, as returned by the
open
function,
are one example. For the most part you can ignore these printed
results. There is one unfortunate feature, however: the form
#<...>
means that there is no printed form of this data type
that the Lisp reader can understand. As a result, if you forget to give
your plot a name you can't cut and paste the result into a
def
expression -- you have to redo the plot or use the history
mechanism.
- ...message
- To keep things simple I will use the term
message
to refer to a message corresponding to a message selector.
- ...expression
-
dotimes
is one of several Lisp looping constructs. It is
a special form with the syntax
(dotimes (var count) expr ....)
.
The loop is repeated
count
times, with
var
bound to 0, 1,
...,
count
- 1. Other looping constructs are
dolist
,
do
and
do*
.
- ...like
- Recall from Section
6.5
that
#<Object: 1966006, prototype = REGRESSION-MODEL-PROTO>
is the
printed representation of the model object returned by
regression-model
. Unfortunately you can't cut and paste it
into the
def
, but of course you can cut and paste the
regression-model
expression or use the history mechanism.
- ...messages
- Ordinarily the entries in the lists returned by these messages
correspond simply to the intercept, if one is included in the model,
followed by the independent variables as they were supplied to
regression-model
. However, if degeneracy is detected during
computations some variables will not be used in the fit; they will be
marked as
aliased
in the printed summary. The indices of the
variables used can be obtained by the
:basis
message; the
entries in the list returned by
:coef-estimates
correspond to
the intercept, if appropriate, followed by the coefficients of the
elements in the basis. The messages
:x-matrix
and
:xtxinv
are similar in that they use only the
variables in the basis.
- ...as
- The / function is used here with three arguments.
The first argument is divided by the second, and the result is then
divided by the third. Thus the result of the expression (/ 6 3 2) is
1.
- ...object.
- The discussion in this section only scratches the surface of
what you can do with functions in the XLISP language. To see more examples
you can look at the files that are loaded when XLISP-STAT starts up.
For more information on options of function definition, macros, etc. see the
XLISP documentation and the books on Lisp mentioned in the references.
- ...results
-
mapcar
can be given several lists after the function.
The function must take as many arguments as there are lists.
mapcar
will apply the function using the first element of
each list, then using the second element, and so on, until one of the lists
is exhausted, and return a list of the results.
- ...reader.
- You should quote an array if you type it in
using this form, as the value of an array is not defined.
- ...object:
- Recall that the expression
#'f1
is short for
(function f1)
and is used for obtaining the function definition
associated with the symbol
f1
.
- ...numerically.
- The maximizing value for 60#60 is always the sample mean.
We could take advantage of this fact and reduce the problem to a one
dimensional maximization problem, but it is simpler to just maximize
over both parameters.
- ...T.
- The function
newtonmax
ordinarily uses numerical derivatives in its
computations. Occasionally this may not be accurate enough or may take
too long. If you have an expression for computing the gradient or the
Hessian then you can use these by having your function return a list
of the function value and the gradient, or a list of the function
value, the gradient and the Hessian matrix, instead of just returning
the function value.
- ...parameters.
- The approximation methods assume these functions
are twice continuously differentiable; thus they can not be indicator
functions.
- ..."-lcmlib".
- There
may be slight differences in the implementation of
dyn-load
on
different systems. The help information for this function should give
information that is appropriate for your system.
Anthony Rossini
Fri Oct 20 10:29:17 EDT 1995