3 ;;; Time-stamp: <2009-12-06 10:05:51 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:
20 (ls-user :depends-on lisp-stat
)
21 (lisp-stat :depends-on
'(cls-dataframe
25 (cls-dataframe :depends-on cls-data
)
32 (defpackage :lisp-stat-config
33 (:documentation
"global settings and variables. Probably need a
34 localization tool as well.")
36 (:export
*common-lisp-stat-version
*
37 *default-path
* *lsos-files
* *basic-files
* *ls-files
*
38 ;; *lispstat-home-dir* *lispstat-data-dir* *lispstat-examples-dir*
40 *cls-data-dir
* *cls-home-dir
* *cls-examples-dir
*))
42 (defpackage :lisp-stat-object-system
43 (:nicknames
:ls-objects
:lsos
)
45 (:shadow
:call-method
:call-next-method
)
46 (:export ls-object objectp
*object
* kind-of-p make-object
48 *set-slot-hook
* proto-slot-value self
49 send call-next-method call-method
50 defmeth defproto instance-slots proto-name
))
52 ;;; -types and -float probably ought to be moved into a -numerics
55 (defpackage :lisp-stat-types
56 (:documentation
"Provides some typeing for LispStat, but is clearly
60 check-nonneg-fixnum check-one-nonneg-fixnum
61 check-one-fixnum check-one-real check-one-number
))
63 (defpackage :lisp-stat-float
65 (:export
+stat-float-typing
+ +stat-cfloat-typing
+ +stat-float-template
+
66 machine-epsilon base-float makedouble
68 make-base-trans-fun-2 make-base-trans-fun
70 base-log base-exp base-expt base-sqrt base-sin base-cos
71 base-tan base-asin base-acos base-atan base-sinh
72 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
73 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
74 BASE-FROUND BASE-SIGNUM BASE-CIS
))
76 ;;; Probably should move into cls-data package.
78 (defpackage :lisp-stat-compound-data
80 :lisp-stat-object-system
82 (:shadowing-import-from
:lisp-stat-object-system
83 call-next-method call-method
)
84 (:export compound-data-p
*compound-data-proto
*
86 compound-data-seq compound-data-length
87 element-list element-seq
89 recursive-map-elements map-elements repeat
91 get-next-element make-next-element set-next-element
94 select split-list which
98 (defpackage :lisp-stat-macros
100 :lisp-stat-compound-data
)
101 (:export make-rv-function make-rv-function-1
))
103 (defpackage :lisp-stat-basics
105 :lisp-stat-object-system
109 :lisp-stat-compound-data
)
110 (:shadowing-import-from
:lisp-stat-object-system
111 call-method call-next-method
)
112 (:export permute-array sum prod count-elements mean
115 (defpackage :lisp-stat-float
117 (:export
+stat-float-typing
+ +stat-cfloat-typing
+ +stat-float-template
+
118 machine-epsilon base-float makedouble
120 make-base-trans-fun-2 make-base-trans-fun
122 BASE-LOG BASE-EXP BASE-EXPT BASE-SQRT BASE-SIN BASE-COS
123 BASE-TAN BASE-ASIN BASE-ACOS BASE-ATAN BASE-SINH
124 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
125 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
126 BASE-FROUND BASE-SIGNUM BASE-CIS
))
128 (defpackage :lisp-stat-macros
130 :lisp-stat-compound-data
)
131 (:export make-rv-function make-rv-function-1
))
134 (defpackage :cls-matrix
135 (:documentation
"basic utilities for using lisp arrays as numerical
136 matrices. Not optimized, and must consider this slow. Routines
137 should be optimized, it is only that we need them first, optimize
140 (:export matrixp num-rows num-cols matmult identity-matrix diagonal
141 row-list column-list inner-product outer-product
142 cross-product transpose bind-columns bind-rows
143 array-data-vector vector-to-array
))
146 ;;; NEW CLOS STRUCTURE
148 ;;; cls-data... in dataframe, though.
149 (defpackage :cls-dataframe
153 (:shadowing-import-from
:xarray slice
)
155 ;; generic container class for data -- if small enough
156 ;; could be value, otherwise might be reference.
162 varlabels caselabels nrows ncols
163 dataframe-dimension dataframe-dimensons
164 xref xtype xdims xdim xrank slice take carray
166 dfref dfref-case dfref-var
167 consistent-dataframe-p
171 list-of-columns
;; list-of-variables
172 list-of-rows
;; list-of-observations
175 (defpackage :cls-data
179 :cls-dataframe
) ; for dataframe
180 (:shadowing-import-from
:xarray slice
)
181 (:export listoflist-
>dataframe
183 listoflist-
>matrix-like
))
190 (defpackage :cls-dataimport
191 (:documentation
"Data I/O and similar import technologies.")
193 :lisp-stat-object-system
197 (:shadowing-import-from
:lisp-stat-object-system
198 call-method call-next-method
)
199 (:export dsvstream-
>dataframe dsvstream-
>matrix dsvstream-
>listoflist
))
202 (defpackage :lisp-stat-model
203 (:documentation
"Model management for data analysis.")
207 ;; data structures for model and model/data combination
208 model statistical-model analysis
))
212 (defpackage :cls-visualize
216 (:shadowing-import-from
:xarray slice
)
220 (defpackage :cls-visualize-plplot
227 plot-ex contour-plot-ex fn-contour-plot-ex shade-plot-ex
3D-plot-ex
))
232 (defpackage :lisp-stat-ffi-int
235 (:export ccl-store-integer ccl-store-double ccl-store-ptr
238 (defpackage :lisp-stat-probability
243 (:export log-gamma set-seed
245 normal-cdf normal-quant normal-dens normal-rand
247 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
248 gamma-cdf gamma-quant gamma-dens gamma-rand
249 chisq-cdf chisq-quant chisq-dens chisq-rand
250 beta-cdf beta-quant beta-dens beta-rand
251 t-cdf t-quant t-dens t-rand
252 f-cdf f-quant f-dens f-rand
253 poisson-cdf poisson-quant poisson-pmf poisson-rand
254 binomial-cdf binomial-quant binomial-pmf binomial-rand
))
258 (defpackage :lisp-stat-math
260 :lisp-stat-object-system
262 :lisp-stat-compound-data
264 (:shadowing-import-from
:lisp-stat-object-system
265 call-method call-next-method
)
266 (:shadow expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
267 asin acos atan sinh cosh tanh asinh acosh atanh float random
268 truncate floor ceiling round minusp zerop plusp evenp oddp
269 < <= = /= >= > ;; complex
270 conjugate realpart imagpart phase
271 min max logand logior logxor lognot ffloor fceiling
272 ftruncate fround signum cis
)
273 (:export ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
274 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
275 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
277 conjugate realpart imagpart phase min max
278 logand logior logxor lognot ffloor fceiling ftruncate fround
280 (:documentation
"Vectorization of numerical functions"))
283 #|
;; some of this goes back in, but not all of it?
284 (defpackage :lisp-stat-linalg
291 :lisp-stat-compound-data
)
292 (:shadowing-import-from
:lisp-stat-math
293 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
294 asin acos atan sinh cosh tanh asinh acosh atanh float random
295 truncate floor ceiling round minusp zerop plusp evenp oddp
296 < <= = /= >= > complex conjugate realpart imagpart phase
297 min max logand logior logxor lognot ffloor fceiling
298 ftruncate fround signum cis
)
299 (:export chol-decomp lu-decomp lu-solve determinant inverse
300 sv-decomp qr-decomp rcondest make-rotation spline
301 kernel-dens kernel-smooth
302 fft make-sweep-matrix sweep-operator ax
+y eigen
304 check-real
;; for optimize
306 covariance-matrix matrix print-matrix solve
307 backsolve eigenvalues eigenvectors accumulate cumsum combine
315 (defpackage :lisp-stat-data
316 (:documentation
"Data management, integration, I/O, and other data technologies.")
317 (:nicknames
:ls-data
)
319 :lisp-stat-object-system
322 :lisp-stat-compound-data
)
323 (:shadowing-import-from
:lisp-stat-object-system
324 call-method call-next-method
)
326 ;; generic structures
328 empirical-statistical-variable
329 modelbased-statistical-variable
330 categorical-statistical-variable
331 nominal-statistical-variable
332 ordinal-statistical-variable
333 continuous-statistical-variable
335 ordering factor-levels nobs support pdmf draw
339 statistical-observation
340 measurement-types record
342 open-file-dialog read-data-file read-data-columns load-data
343 load-example
*variables
* *ask-on-redefine
*
344 def variables savevar undef
))
346 (defpackage :lisp-stat-descriptive-statistics
351 :lisp-stat-compound-data
353 (:shadowing-import-from
:lisp-stat-math
;; life is a vector!
354 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
355 asin acos atan sinh cosh tanh asinh acosh atanh float random
356 truncate floor ceiling round minusp zerop plusp evenp oddp
357 < <= = /= >= > ;; complex
358 conjugate realpart imagpart phase
359 min max logand logior logxor lognot ffloor fceiling
360 ftruncate fround signum cis
)
361 (:export mean standard-deviation variance
362 quantile median interquartile-range
365 (defpackage :lisp-stat-regression-linear
369 :lisp-stat-compound-data
370 :lisp-stat-descriptive-statistics
)
371 (:shadowing-import-from
:lisp-stat-object-system
372 call-method call-next-method
)
373 (:export regression-model fit-model
375 estimates covariance-matrix
376 ;; functions for helpers
378 print-object
;; for method dispatch
381 (defpackage :common-lisp-statistics
382 (:documentation
"Experimentation package for LispStat. Serious work
383 should be packaged up as a separate but similar package to help
384 drive reproducibility. By this I mean, creating a
385 data/analytics/analysis package with the minimal set of
386 objects/packages required.")
387 (:nicknames
:cls
:common-lisp-statistics
:lisp-stat
)
389 :xarray
;; generic reference -- internally supporting array, lol structs
390 :lisp-matrix
;; conversion to a more robust linalg approach
392 :lisp-stat-object-system
393 :lisp-stat-compound-data
394 :lisp-stat-probability
402 :lisp-stat-descriptive-statistics
403 :lisp-stat-regression-linear
406 ;; :cls-visualize-plplot
408 (:shadowing-import-from
:xarray slice
)
409 (:shadowing-import-from
:lisp-stat-object-system
410 call-method call-next-method
)
411 (:shadowing-import-from
:lisp-stat-math
412 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
413 asin acos atan sinh cosh tanh asinh acosh atanh float random
414 truncate floor ceiling round minusp zerop plusp evenp oddp
417 conjugate realpart imagpart phase
420 logand logior logxor lognot
421 ffloor fceiling ftruncate fround
425 *default-path
* *lsos-files
* *basic-files
* *ls-files
*
426 *lispstat-home-dir
* *lispstat-data-dir
* *lispstat-examples-dir
*
430 defmeth send proto-slot-value
433 fixnump check-nonneg-fixnum check-one-fixnum
434 check-one-nonneg-fixnum
435 check-one-real check-one-number
443 compound-data-p
*compound-data-proto
* compound-object-p
444 compound-data-seq compound-data-length
445 element-list element-seq
447 recursive-map-elements map-elements
450 get-next-element make-next-element set-next-element
458 ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
459 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
460 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
462 conjugate realpart imagpart phase min max
463 logand logior logxor lognot ffloor fceiling ftruncate fround
466 #|
;; The following need to be re-found in lisp-matrix...
469 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
470 column-list inner-product outer-product cross-product transpose
471 bind-columns bind-rows
474 chol-decomp lu-decomp lu-solve determinant inverse
475 sv-decomp qr-decomp rcondest make-rotation spline
476 kernel-dens kernel-smooth
477 fft make-sweep-matrix sweep-operator ax
+y eigen
479 covariance-matrix matrix print-matrix solve
480 backsolve eigenvalues eigenvectors accumulate cumsum combine
483 ;; in linalg.lisp, possibly not supported by matlisp
484 spline kernel-dens kernel-smooth
492 make-rv-function make-rv-function-1
495 xref xtype xdims xdim xdims
*
496 lists-of-same-size equal-listoflist transpose-listoflist
499 ;; need to take this list and make it strings... specs could mean
500 ;; that we process the strings in different ways?
504 (mapc #'symbol-for-symbol-to-string-or-symbol
505 (do-external-symbols (s (find-package 'lisp-stat-data
) lst
) (push s lst
))))
508 open-file-dialog read-data-file read-data-columns load-data
509 load-example
*variables
* *ask-on-redefine
*
510 def variables savevar undef
512 dataframe-like dataframe-array make-dataframe
513 varlabels caselabels nrows ncols
514 dataframe-dimension dataframe-dimensons
515 dfref dfref-case dfref-var
516 consistent-dataframe-p
517 dataset list-of-columns list-of-rows
520 listoflist-
>dataframe listoflist-
>array listoflist-
>matrix-like
522 ;; statistics.lsp (descriptions, should probably be moved
524 standard-deviation quantile median interquartile-range
527 ;; probability (dists.lisp)
529 uniform-rand normal-cdf normal-quant normal-dens
530 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
531 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
532 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
533 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
534 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
535 binomial-cdf binomial-quant binomial-pmf binomial-rand
537 ;; Here is where we have a problem -- lispstat core should be core
538 ;; data management and config problems, with packages providing
539 ;; specialized extensions to LispStat, i.e. regression, nonlin
540 ;; regression, bayesian regression via laplace approximation, etc.
542 ;; The following could be considered "recommended packages",
543 ;; similar to the idea of the recommended packages in R. Probably
544 ;; we want them to do the exporting within that package, therefore
545 ;; NOT being able to lock the "data-ish" package, but only the
546 ;; subpackages prior to export.
549 ;; -- linear regressin models.
550 regression-model fit-model
551 estimates covariance-matrix
553 regression-model-proto x y intercept sweep-matrix
554 basis weights included total-sum-of-squares residual-sum-of-squares
555 predictor-names response-name case-labels
559 ;; -- nonlinear regression models
560 nreg-model nreg-model-proto mean-function theta-hat epsilon
562 ;; we might need something like xtxinv here? But should be
563 ;; encapsulated, so we use the one in regression.lisp
566 bayes-model bayes-model-proto bayes-internals
578 ;;;; PACKAGES FOR USEABILITY
580 (defpackage :lisp-stat-data-examples
581 (:documentation
"Example data for unittests, examples, illustrations,")
583 :common-lisp-statistics
)
584 (:shadowing-import-from
:lisp-stat
585 call-method call-next-method
587 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
588 asin acos atan sinh cosh tanh asinh acosh atanh float random
589 truncate floor ceiling round minusp zerop plusp evenp oddp
590 < <= = /= >= > > ;; complex
591 conjugate realpart imagpart phase
592 min max logand logior logxor lognot ffloor fceiling
593 ftruncate fround signum cis
596 (:export iron aluminum absorbtion
600 (defpackage :lisp-stat-user
601 (:documentation
"Experimentation package for LispStat. Serious work
602 should be placed in a similar package elsewhere for
603 reproducibility. But this should hint as to what needs to be done
604 for a user- or analysis-package.")
605 (:nicknames
:ls-user
)
606 (:use
:common-lisp
; always needed for user playgrounds!
608 :common-lisp-statistics
609 :lisp-stat-data-examples
) ;; this last is to have 'things to play with'
610 (:shadowing-import-from
:lisp-stat
611 call-method call-next-method
613 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
614 asin acos atan sinh cosh tanh asinh acosh atanh float random
615 truncate floor ceiling round minusp zerop plusp evenp oddp
616 < <= = /= >= > > ;; complex
617 conjugate realpart imagpart phase
618 min max logand logior logxor lognot ffloor fceiling
619 ftruncate fround signum cis
623 (defpackage :lisp-stat-unittests
626 :lisp-stat
:lisp-stat-data-examples
)
627 (:shadowing-import-from
:lisp-stat
628 call-method call-next-method
;; objects
629 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
;; lsmath
630 asin acos atan sinh cosh tanh asinh acosh atanh float random
631 truncate floor ceiling round minusp zerop plusp evenp oddp
632 < <= = /= >= > ;; complex
633 conjugate realpart imagpart phase
634 min max logand logior logxor lognot ffloor fceiling
635 ftruncate fround signum cis
)
636 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard
; exec
637 almost
= almost
=lists numerical
=)) ; compare
639 (defpackage :cls-dataframe-example
641 :lift
:lisp-stat-unittests
642 :lisp-stat-data-examples
644 (:export absorbtion aluminum iron
))
647 (defpackage :lisp-stat-optimize
652 :lisp-stat-object-system
654 :lisp-stat-compound-data
660 :lisp-stat-linalg-data
664 (:shadowing-import-from
:lisp-stat-object-system
665 call-method call-next-method
)
666 (:shadowing-import-from
:lisp-stat-math
667 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
668 asin acos atan sinh cosh tanh asinh acosh atanh float random
669 truncate floor ceiling round minusp zerop plusp evenp oddp
670 < <= = /= >= > complex conjugate realpart imagpart phase
671 min max logand logior logxor lognot ffloor fceiling
672 ftruncate fround signum cis
)
678 newtonmax nelmeadmax
))