3 ;;; Time-stamp: <2009-12-23 14:31:44 tony>
4 ;;; Creation: <2008-03-11 19:18:34 user>
5 ;;; File: packages.lisp
6 ;;; Author: AJ Rossini <blindglobe@gmail.com>
7 ;;; Copyright: (c)2007--2008, AJ Rossini. BSD, LLGPL, or GPLv2, depending
9 ;;; Purpose: package structure description for lispstat
11 ;;; What is this talk of 'release'? Klingons do not make software
12 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
13 ;;; designers and quality assurance people in its wake.
17 ;;; Current structure, dependencies:
19 '((:ls-user
:depends-on lisp-stat
)
20 (:lisp-stat
:depends-on
'(cls-dataframe
24 (:cls-data
:depends-on
)
25 (:cls-dataframe
:depends-on cls-data
)
34 (defpackage :lisp-stat-object-system
35 (:nicknames
:ls-objects
:lsos
)
37 (:shadow
:call-method
:call-next-method
)
38 (:export ls-object objectp
*object
* kind-of-p make-object
40 *set-slot-hook
* proto-slot-value self
41 send call-next-method call-method
42 defmeth defproto instance-slots proto-name
))
44 ;;; -types and -float probably ought to be moved into a -numerics
47 (defpackage :lisp-stat-types
48 (:documentation
"Provides some typeing for LispStat, but is clearly
52 check-nonneg-fixnum check-one-nonneg-fixnum
53 check-one-fixnum check-one-real check-one-number
))
55 (defpackage :lisp-stat-float
57 (:export
+stat-float-typing
+ +stat-cfloat-typing
+ +stat-float-template
+
58 machine-epsilon base-float makedouble
60 make-base-trans-fun-2 make-base-trans-fun
62 base-log base-exp base-expt base-sqrt base-sin base-cos
63 base-tan base-asin base-acos base-atan base-sinh
64 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
65 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
66 BASE-FROUND BASE-SIGNUM BASE-CIS
))
68 ;;; Probably should move into cls-data package.
70 (defpackage :lisp-stat-compound-data
72 :lisp-stat-object-system
74 (:shadowing-import-from
:lisp-stat-object-system
75 call-next-method call-method
)
76 (:export compound-data-p
*compound-data-proto
*
78 compound-data-seq compound-data-length
79 element-list element-seq
81 recursive-map-elements map-elements repeat
83 get-next-element make-next-element set-next-element
86 select split-list which
90 (defpackage :lisp-stat-macros
92 :lisp-stat-compound-data
)
93 (:export make-rv-function make-rv-function-1
))
95 (defpackage :lisp-stat-basics
97 :lisp-stat-object-system
101 :lisp-stat-compound-data
)
102 (:shadowing-import-from
:lisp-stat-object-system
103 call-method call-next-method
)
104 (:export permute-array sum prod count-elements mean
107 (defpackage :lisp-stat-float
109 (:export
+stat-float-typing
+ +stat-cfloat-typing
+ +stat-float-template
+
110 machine-epsilon base-float makedouble
112 make-base-trans-fun-2 make-base-trans-fun
114 BASE-LOG BASE-EXP BASE-EXPT BASE-SQRT BASE-SIN BASE-COS
115 BASE-TAN BASE-ASIN BASE-ACOS BASE-ATAN BASE-SINH
116 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
117 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
118 BASE-FROUND BASE-SIGNUM BASE-CIS
))
120 (defpackage :lisp-stat-macros
122 :lisp-stat-compound-data
)
123 (:export make-rv-function make-rv-function-1
))
126 (defpackage :cls-matrix
127 (:documentation
"basic utilities for using lisp arrays as numerical
128 matrices. Not optimized, and must consider this slow. Routines
129 should be optimized, it is only that we need them first, optimize
132 (:export matrixp num-rows num-cols matmult identity-matrix diagonal
133 row-list column-list inner-product outer-product
134 cross-product transpose bind-columns bind-rows
135 array-data-vector vector-to-array
))
138 ;;; NEW CLOS STRUCTURE
140 ;; CLS-DATA contains the basic variable structure, classes, support/indexing, and mixins.
141 ;; CLS-DATAFRAME leverages CLS-DATA, XARRAY, and LISP-MATRIX
142 ;; CLS-DATAIO stores/saves structures
143 ;; CLS-DATATRANS converts between structures, and from DATAFRAMES to MODEL-MATRIXES
145 (defpackage :cls-data
147 (:shadowing-import-from
:xarray slice
)
149 ;; must work out what is needed for stat variable metadata, support
153 ;;; cls-data... in dataframe, though.
154 (defpackage :cls-dataframe
159 (:shadowing-import-from
:xarray slice
)
161 ;; generic container class for data -- if small enough
162 ;; could be value, otherwise might be reference.
168 list-of-columns
;; list-of-variables
169 list-of-rows
;; list-of-observations
172 varlabels caselabels nrows ncols
173 dataframe-dimension dataframe-dimensons
174 xref xtype xdims xdim xrank slice take carray
180 (defpackage :cls-dataio
181 (:documentation
"Data I/O and similar import technologies.")
183 :lisp-stat-object-system
187 (:shadowing-import-from
:lisp-stat-object-system
188 call-method call-next-method
)
189 (:export dsvstream-
>dataframe dsvstream-
>matrix dsvstream-
>listoflist
))
191 (defpackage :cls-datatrans
192 (:documentation
"Data I/O and similar import technologies.")
194 :lisp-stat-object-system
198 (:shadowing-import-from
:lisp-stat-object-system
199 call-method call-next-method
)
200 (:export dsvstream-
>dataframe dsvstream-
>matrix dsvstream-
>listoflist
202 listoflist-
>dataframe
204 listoflist-
>matrix-like
205 filename.dsv-
>dataframe
))
209 (defpackage :lisp-stat-model
210 (:documentation
"Model management for data analysis.")
214 ;; data structures for model and model/data combination
215 model statistical-model analysis
))
219 (defpackage :cls-visualize
223 (:shadowing-import-from
:xarray slice
)
227 (defpackage :cls-visualize-plplot
234 plot-ex contour-plot-ex fn-contour-plot-ex shade-plot-ex
3D-plot-ex
))
239 (defpackage :lisp-stat-ffi-int
242 (:export ccl-store-integer ccl-store-double ccl-store-ptr
245 (defpackage :lisp-stat-probability
250 (:export log-gamma set-seed
252 normal-cdf normal-quant normal-dens normal-rand
254 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
255 gamma-cdf gamma-quant gamma-dens gamma-rand
256 chisq-cdf chisq-quant chisq-dens chisq-rand
257 beta-cdf beta-quant beta-dens beta-rand
258 t-cdf t-quant t-dens t-rand
259 f-cdf f-quant f-dens f-rand
260 poisson-cdf poisson-quant poisson-pmf poisson-rand
261 binomial-cdf binomial-quant binomial-pmf binomial-rand
))
265 (defpackage :lisp-stat-math
267 :lisp-stat-object-system
269 :lisp-stat-compound-data
271 (:shadowing-import-from
:lisp-stat-object-system
272 call-method call-next-method
)
273 (:shadow expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
274 asin acos atan sinh cosh tanh asinh acosh atanh float random
275 truncate floor ceiling round minusp zerop plusp evenp oddp
276 < <= = /= >= > ;; complex
277 conjugate realpart imagpart phase
278 min max logand logior logxor lognot ffloor fceiling
279 ftruncate fround signum cis
)
280 (:export ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
281 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
282 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
284 conjugate realpart imagpart phase min max
285 logand logior logxor lognot ffloor fceiling ftruncate fround
287 (:documentation
"Vectorization of numerical functions"))
290 #|
;; some of this goes back in, but not all of it?
291 (defpackage :lisp-stat-linalg
298 :lisp-stat-compound-data
)
299 (:shadowing-import-from
:lisp-stat-math
300 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
301 asin acos atan sinh cosh tanh asinh acosh atanh float random
302 truncate floor ceiling round minusp zerop plusp evenp oddp
303 < <= = /= >= > complex conjugate realpart imagpart phase
304 min max logand logior logxor lognot ffloor fceiling
305 ftruncate fround signum cis
)
306 (:export chol-decomp lu-decomp lu-solve determinant inverse
307 sv-decomp qr-decomp rcondest make-rotation spline
308 kernel-dens kernel-smooth
309 fft make-sweep-matrix sweep-operator ax
+y eigen
311 check-real
;; for optimize
313 covariance-matrix matrix print-matrix solve
314 backsolve eigenvalues eigenvectors accumulate cumsum combine
322 (defpackage :lisp-stat-data
323 (:documentation
"Data management, integration, I/O, and other data technologies.")
324 (:nicknames
:ls-data
)
326 :lisp-stat-object-system
329 :lisp-stat-compound-data
)
330 (:shadowing-import-from
:lisp-stat-object-system
331 call-method call-next-method
)
333 ;; generic structures
335 empirical-statistical-variable
336 modelbased-statistical-variable
337 categorical-statistical-variable
338 nominal-statistical-variable
339 ordinal-statistical-variable
340 continuous-statistical-variable
342 ordering factor-levels nobs support pdmf draw
346 statistical-observation
347 measurement-types record
349 open-file-dialog read-data-file read-data-columns load-data
350 load-example
*variables
* *ask-on-redefine
*
351 def variables savevar undef
))
353 (defpackage :lisp-stat-descriptive-statistics
358 :lisp-stat-compound-data
360 (:shadowing-import-from
:lisp-stat-math
;; life is a vector!
361 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
362 asin acos atan sinh cosh tanh asinh acosh atanh float random
363 truncate floor ceiling round minusp zerop plusp evenp oddp
364 < <= = /= >= > ;; complex
365 conjugate realpart imagpart phase
366 min max logand logior logxor lognot ffloor fceiling
367 ftruncate fround signum cis
)
368 (:export mean standard-deviation variance
369 quantile median interquartile-range
372 (defpackage :lisp-stat-regression-linear
376 :lisp-stat-compound-data
377 :lisp-stat-descriptive-statistics
)
378 (:shadowing-import-from
:lisp-stat-object-system
379 call-method call-next-method
)
380 (:export regression-model fit-model
382 estimates covariance-matrix
383 ;; functions for helpers
385 print-object
;; for method dispatch
388 (defpackage :common-lisp-statistics
389 (:documentation
"Experimentation package for LispStat. Serious work
390 should be packaged up as a separate but similar package to help
391 drive reproducibility. By this I mean, creating a
392 data/analytics/analysis package with the minimal set of
393 objects/packages required.")
394 (:nicknames
:cls
:common-lisp-statistics
:lisp-stat
)
396 :xarray
;; generic reference -- internally supporting array, lol structs
398 :lisp-matrix
;; conversion to a more robust linalg approach
400 :lisp-stat-object-system
401 :lisp-stat-compound-data
402 :lisp-stat-probability
410 :lisp-stat-descriptive-statistics
411 :lisp-stat-regression-linear
414 ;; :cls-visualize-plplot
416 (:shadowing-import-from
:xarray slice
)
417 (:shadowing-import-from
:lisp-stat-object-system
418 call-method call-next-method
)
419 (:shadowing-import-from
:lisp-stat-math
420 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
421 asin acos atan sinh cosh tanh asinh acosh atanh float random
422 truncate floor ceiling round minusp zerop plusp evenp oddp
425 conjugate realpart imagpart phase
428 logand logior logxor lognot
429 ffloor fceiling ftruncate fround
433 *default-path
* *lsos-files
* *basic-files
* *ls-files
*
434 *cls-home-dir
* *cls-data-dir
* *cls-examples-dir
*
438 defmeth send proto-slot-value
441 fixnump check-nonneg-fixnum check-one-fixnum
442 check-one-nonneg-fixnum
443 check-one-real check-one-number
451 compound-data-p
*compound-data-proto
* compound-object-p
452 compound-data-seq compound-data-length
453 element-list element-seq
455 recursive-map-elements map-elements
458 get-next-element make-next-element set-next-element
466 ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
467 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
468 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
470 conjugate realpart imagpart phase min max
471 logand logior logxor lognot ffloor fceiling ftruncate fround
474 #|
;; The following need to be re-found in lisp-matrix...
477 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
478 column-list inner-product outer-product cross-product transpose
479 bind-columns bind-rows
482 chol-decomp lu-decomp lu-solve determinant inverse
483 sv-decomp qr-decomp rcondest make-rotation spline
484 kernel-dens kernel-smooth
485 fft make-sweep-matrix sweep-operator ax
+y eigen
487 covariance-matrix matrix print-matrix solve
488 backsolve eigenvalues eigenvectors accumulate cumsum combine
491 ;; in linalg.lisp, possibly not supported by matlisp
492 spline kernel-dens kernel-smooth
499 ;; package LISPSTAT-MACROS
500 make-rv-function make-rv-function-1
503 xref xtype xdims xdim xdims
*
505 ;; package LISTOFLIST
506 sublists-of-same-size-p equal-listoflist transpose-listoflist
509 ;; need to take this list and make it symbols... specs could mean
510 ;; that we process the strings in different ways? Create such a
511 ;; macro to enable export within this package?
515 (mapc #'symbol-for-symbol-to-string-or-symbol
516 (do-external-symbols (s (find-package 'lisp-stat-data
) lst
) (push s lst
))))
519 open-file-dialog read-data-file read-data-columns load-data
520 load-example
*variables
* *ask-on-redefine
*
521 def variables savevar undef
523 dataframe-like dataframe-array make-dataframe
524 varlabels caselabels nrows ncols
525 dataframe-dimension dataframe-dimensons
526 dfref dfref-case dfref-var
527 consistent-dataframe-p
528 dataset list-of-columns list-of-rows
532 listoflist-
>dataframe listoflist-
>array listoflist-
>matrix-like
533 sublists-of-same-size-p
535 ;; statistics.lsp (descriptions, should probably be moved
537 standard-deviation quantile median interquartile-range
540 ;; probability (dists.lisp)
542 uniform-rand normal-cdf normal-quant normal-dens
543 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
544 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
545 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
546 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
547 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
548 binomial-cdf binomial-quant binomial-pmf binomial-rand
550 ;; Here is where we have a problem -- lispstat core should be core
551 ;; data management and config problems, with packages providing
552 ;; specialized extensions to LispStat, i.e. regression, nonlin
553 ;; regression, bayesian regression via laplace approximation, etc.
555 ;; The following could be considered "recommended packages",
556 ;; similar to the idea of the recommended packages in R. Probably
557 ;; we want them to do the exporting within that package, therefore
558 ;; NOT being able to lock the "data-ish" package, but only the
559 ;; subpackages prior to export.
562 ;; -- linear regressin models.
563 regression-model fit-model
564 estimates covariance-matrix
566 regression-model-proto x y intercept sweep-matrix
567 basis weights included total-sum-of-squares residual-sum-of-squares
568 predictor-names response-name case-labels
572 ;; -- nonlinear regression models
573 nreg-model nreg-model-proto mean-function theta-hat epsilon
575 ;; we might need something like xtxinv here? But should be
576 ;; encapsulated, so we use the one in regression.lisp
579 bayes-model bayes-model-proto bayes-internals
591 ;;;; PACKAGES FOR USEABILITY
593 (defpackage :lisp-stat-data-examples
594 (:documentation
"Example data for unittests, examples, illustrations,")
596 :common-lisp-statistics
)
597 (:shadowing-import-from
:lisp-stat
598 call-method call-next-method
600 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
601 asin acos atan sinh cosh tanh asinh acosh atanh float random
602 truncate floor ceiling round minusp zerop plusp evenp oddp
603 < <= = /= >= > > ;; complex
604 conjugate realpart imagpart phase
605 min max logand logior logxor lognot ffloor fceiling
606 ftruncate fround signum cis
609 (:export iron aluminum absorbtion
613 (defpackage :lisp-stat-user
614 (:documentation
"Experimentation package for LispStat. Serious work
615 should be placed in a similar package elsewhere for
616 reproducibility. But this should hint as to what needs to be done
617 for a user- or analysis-package.")
618 (:nicknames
:ls-user
:cls-user
)
619 (:use
:common-lisp
; always needed for user playgrounds!
621 :common-lisp-statistics
622 :lisp-stat-data-examples
) ;; this last is to have 'things to play with'
623 (:shadowing-import-from
:lisp-stat
624 call-method call-next-method
626 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
627 asin acos atan sinh cosh tanh asinh acosh atanh float random
628 truncate floor ceiling round minusp zerop plusp evenp oddp
629 < <= = /= >= > > ;; complex
630 conjugate realpart imagpart phase
631 min max logand logior logxor lognot ffloor fceiling
632 ftruncate fround signum cis
636 (defpackage :lisp-stat-unittests
639 :lisp-stat
:lisp-stat-data-examples
)
640 (:shadowing-import-from
:lisp-stat
641 call-method call-next-method
;; objects
642 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
;; lsmath
643 asin acos atan sinh cosh tanh asinh acosh atanh float random
644 truncate floor ceiling round minusp zerop plusp evenp oddp
645 < <= = /= >= > ;; complex
646 conjugate realpart imagpart phase
647 min max logand logior logxor lognot ffloor fceiling
648 ftruncate fround signum cis
)
649 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard
; exec
650 almost
= almost
=lists numerical
=)) ; compare
652 (defpackage :cls-dataframe-example
654 :lift
:lisp-stat-unittests
655 :lisp-stat-data-examples
657 (:export absorbtion aluminum iron
))
660 (defpackage :lisp-stat-optimize
665 :lisp-stat-object-system
667 :lisp-stat-compound-data
673 :lisp-stat-linalg-data
677 (:shadowing-import-from
:lisp-stat-object-system
678 call-method call-next-method
)
679 (:shadowing-import-from
:lisp-stat-math
680 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
681 asin acos atan sinh cosh tanh asinh acosh atanh float random
682 truncate floor ceiling round minusp zerop plusp evenp oddp
683 < <= = /= >= > complex conjugate realpart imagpart phase
684 min max logand logior logxor lognot ffloor fceiling
685 ftruncate fround signum cis
)
691 newtonmax nelmeadmax
))