3 ;;; Time-stamp: <2009-12-23 14:41:54 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.")
184 :lisp-stat-object-system
187 (:shadowing-import-from
:lisp-stat-object-system
188 call-method call-next-method
)
189 (:export dsvstream-
>dataframe
191 dsvstream-
>listoflist
193 filename.dsv-
>dataframe
196 (defpackage :cls-datatrans
197 (:documentation
"Data I/O and similar import technologies.")
200 :lisp-stat-object-system
203 (:shadowing-import-from
:lisp-stat-object-system
204 call-method call-next-method
)
205 (:export listoflist-
>dataframe dataframe-
>listoflist
206 listoflist-
>array array-
>listoflist
207 listoflist-
>matrix-like matrix-like-
>listoflist
213 (defpackage :lisp-stat-model
214 (:documentation
"Model management for data analysis.")
218 ;; data structures for model and model/data combination
219 model statistical-model analysis
))
223 (defpackage :cls-visualize
227 (:shadowing-import-from
:xarray slice
)
231 (defpackage :cls-visualize-plplot
238 plot-ex contour-plot-ex fn-contour-plot-ex shade-plot-ex
3D-plot-ex
))
243 (defpackage :lisp-stat-ffi-int
246 (:export ccl-store-integer ccl-store-double ccl-store-ptr
249 (defpackage :lisp-stat-probability
254 (:export log-gamma set-seed
256 normal-cdf normal-quant normal-dens normal-rand
258 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
259 gamma-cdf gamma-quant gamma-dens gamma-rand
260 chisq-cdf chisq-quant chisq-dens chisq-rand
261 beta-cdf beta-quant beta-dens beta-rand
262 t-cdf t-quant t-dens t-rand
263 f-cdf f-quant f-dens f-rand
264 poisson-cdf poisson-quant poisson-pmf poisson-rand
265 binomial-cdf binomial-quant binomial-pmf binomial-rand
))
269 (defpackage :lisp-stat-math
271 :lisp-stat-object-system
273 :lisp-stat-compound-data
275 (:shadowing-import-from
:lisp-stat-object-system
276 call-method call-next-method
)
277 (:shadow expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
278 asin acos atan sinh cosh tanh asinh acosh atanh float random
279 truncate floor ceiling round minusp zerop plusp evenp oddp
280 < <= = /= >= > ;; complex
281 conjugate realpart imagpart phase
282 min max logand logior logxor lognot ffloor fceiling
283 ftruncate fround signum cis
)
284 (:export ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
285 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
286 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
288 conjugate realpart imagpart phase min max
289 logand logior logxor lognot ffloor fceiling ftruncate fround
291 (:documentation
"Vectorization of numerical functions"))
294 #|
;; some of this goes back in, but not all of it?
295 (defpackage :lisp-stat-linalg
302 :lisp-stat-compound-data
)
303 (:shadowing-import-from
:lisp-stat-math
304 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
305 asin acos atan sinh cosh tanh asinh acosh atanh float random
306 truncate floor ceiling round minusp zerop plusp evenp oddp
307 < <= = /= >= > complex conjugate realpart imagpart phase
308 min max logand logior logxor lognot ffloor fceiling
309 ftruncate fround signum cis
)
310 (:export chol-decomp lu-decomp lu-solve determinant inverse
311 sv-decomp qr-decomp rcondest make-rotation spline
312 kernel-dens kernel-smooth
313 fft make-sweep-matrix sweep-operator ax
+y eigen
315 check-real
;; for optimize
317 covariance-matrix matrix print-matrix solve
318 backsolve eigenvalues eigenvectors accumulate cumsum combine
326 (defpackage :lisp-stat-data
327 (:documentation
"Data management, integration, I/O, and other data technologies.")
328 (:nicknames
:ls-data
)
330 :lisp-stat-object-system
333 :lisp-stat-compound-data
)
334 (:shadowing-import-from
:lisp-stat-object-system
335 call-method call-next-method
)
337 ;; generic structures
339 empirical-statistical-variable
340 modelbased-statistical-variable
341 categorical-statistical-variable
342 nominal-statistical-variable
343 ordinal-statistical-variable
344 continuous-statistical-variable
346 ordering factor-levels nobs support pdmf draw
350 statistical-observation
351 measurement-types record
353 open-file-dialog read-data-file read-data-columns load-data
354 load-example
*variables
* *ask-on-redefine
*
355 def variables savevar undef
))
357 (defpackage :lisp-stat-descriptive-statistics
362 :lisp-stat-compound-data
364 (:shadowing-import-from
:lisp-stat-math
;; life is a vector!
365 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
366 asin acos atan sinh cosh tanh asinh acosh atanh float random
367 truncate floor ceiling round minusp zerop plusp evenp oddp
368 < <= = /= >= > ;; complex
369 conjugate realpart imagpart phase
370 min max logand logior logxor lognot ffloor fceiling
371 ftruncate fround signum cis
)
372 (:export mean standard-deviation variance
373 quantile median interquartile-range
376 (defpackage :lisp-stat-regression-linear
380 :lisp-stat-compound-data
381 :lisp-stat-descriptive-statistics
)
382 (:shadowing-import-from
:lisp-stat-object-system
383 call-method call-next-method
)
384 (:export regression-model fit-model
386 estimates covariance-matrix
387 ;; functions for helpers
389 print-object
;; for method dispatch
392 (defpackage :common-lisp-statistics
393 (:documentation
"Experimentation package for LispStat. Serious work
394 should be packaged up as a separate but similar package to help
395 drive reproducibility. By this I mean, creating a
396 data/analytics/analysis package with the minimal set of
397 objects/packages required.")
398 (:nicknames
:cls
:common-lisp-statistics
:lisp-stat
)
400 :xarray
;; generic reference -- internally supporting array, lol structs
402 :lisp-matrix
;; conversion to a more robust linalg approach
404 :lisp-stat-object-system
405 :lisp-stat-compound-data
406 :lisp-stat-probability
414 :lisp-stat-descriptive-statistics
415 :lisp-stat-regression-linear
418 ;; :cls-visualize-plplot
420 (:shadowing-import-from
:xarray slice
)
421 (:shadowing-import-from
:lisp-stat-object-system
422 call-method call-next-method
)
423 (:shadowing-import-from
:lisp-stat-math
424 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
425 asin acos atan sinh cosh tanh asinh acosh atanh float random
426 truncate floor ceiling round minusp zerop plusp evenp oddp
429 conjugate realpart imagpart phase
432 logand logior logxor lognot
433 ffloor fceiling ftruncate fround
437 *default-path
* *lsos-files
* *basic-files
* *ls-files
*
438 *cls-home-dir
* *cls-data-dir
* *cls-examples-dir
*
442 defmeth send proto-slot-value
445 fixnump check-nonneg-fixnum check-one-fixnum
446 check-one-nonneg-fixnum
447 check-one-real check-one-number
455 compound-data-p
*compound-data-proto
* compound-object-p
456 compound-data-seq compound-data-length
457 element-list element-seq
459 recursive-map-elements map-elements
462 get-next-element make-next-element set-next-element
470 ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
471 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
472 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
474 conjugate realpart imagpart phase min max
475 logand logior logxor lognot ffloor fceiling ftruncate fround
478 #|
;; The following need to be re-found in lisp-matrix...
481 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
482 column-list inner-product outer-product cross-product transpose
483 bind-columns bind-rows
486 chol-decomp lu-decomp lu-solve determinant inverse
487 sv-decomp qr-decomp rcondest make-rotation spline
488 kernel-dens kernel-smooth
489 fft make-sweep-matrix sweep-operator ax
+y eigen
491 covariance-matrix matrix print-matrix solve
492 backsolve eigenvalues eigenvectors accumulate cumsum combine
495 ;; in linalg.lisp, possibly not supported by matlisp
496 spline kernel-dens kernel-smooth
503 ;; package LISPSTAT-MACROS
504 make-rv-function make-rv-function-1
507 xref xtype xdims xdim xdims
*
509 ;; package LISTOFLIST
510 sublists-of-same-size-p equal-listoflist transpose-listoflist
513 ;; need to take this list and make it symbols... specs could mean
514 ;; that we process the strings in different ways? Create such a
515 ;; macro to enable export within this package?
519 (mapc #'symbol-for-symbol-to-string-or-symbol
520 (do-external-symbols (s (find-package 'lisp-stat-data
) lst
) (push s lst
))))
523 open-file-dialog read-data-file read-data-columns load-data
524 load-example
*variables
* *ask-on-redefine
*
525 def variables savevar undef
527 dataframe-like dataframe-array make-dataframe
528 varlabels caselabels nrows ncols
529 dataframe-dimension dataframe-dimensons
530 dfref dfref-case dfref-var
531 consistent-dataframe-p
532 dataset list-of-columns list-of-rows
536 listoflist-
>dataframe listoflist-
>array listoflist-
>matrix-like
537 sublists-of-same-size-p
539 ;; statistics.lsp (descriptions, should probably be moved
541 standard-deviation quantile median interquartile-range
544 ;; probability (dists.lisp)
546 uniform-rand normal-cdf normal-quant normal-dens
547 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
548 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
549 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
550 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
551 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
552 binomial-cdf binomial-quant binomial-pmf binomial-rand
554 ;; Here is where we have a problem -- lispstat core should be core
555 ;; data management and config problems, with packages providing
556 ;; specialized extensions to LispStat, i.e. regression, nonlin
557 ;; regression, bayesian regression via laplace approximation, etc.
559 ;; The following could be considered "recommended packages",
560 ;; similar to the idea of the recommended packages in R. Probably
561 ;; we want them to do the exporting within that package, therefore
562 ;; NOT being able to lock the "data-ish" package, but only the
563 ;; subpackages prior to export.
566 ;; -- linear regressin models.
567 regression-model fit-model
568 estimates covariance-matrix
570 regression-model-proto x y intercept sweep-matrix
571 basis weights included total-sum-of-squares residual-sum-of-squares
572 predictor-names response-name case-labels
576 ;; -- nonlinear regression models
577 nreg-model nreg-model-proto mean-function theta-hat epsilon
579 ;; we might need something like xtxinv here? But should be
580 ;; encapsulated, so we use the one in regression.lisp
583 bayes-model bayes-model-proto bayes-internals
595 ;;;; PACKAGES FOR USEABILITY
597 (defpackage :lisp-stat-data-examples
598 (:documentation
"Example data for unittests, examples, illustrations,")
600 :common-lisp-statistics
)
601 (:shadowing-import-from
:lisp-stat
602 call-method call-next-method
604 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
605 asin acos atan sinh cosh tanh asinh acosh atanh float random
606 truncate floor ceiling round minusp zerop plusp evenp oddp
607 < <= = /= >= > > ;; complex
608 conjugate realpart imagpart phase
609 min max logand logior logxor lognot ffloor fceiling
610 ftruncate fround signum cis
613 (:export iron aluminum absorbtion
617 (defpackage :lisp-stat-user
618 (:documentation
"Experimentation package for LispStat. Serious work
619 should be placed in a similar package elsewhere for
620 reproducibility. But this should hint as to what needs to be done
621 for a user- or analysis-package.")
622 (:nicknames
:ls-user
:cls-user
)
623 (:use
:common-lisp
; always needed for user playgrounds!
625 :common-lisp-statistics
626 :lisp-stat-data-examples
) ;; this last is to have 'things to play with'
627 (:shadowing-import-from
:lisp-stat
628 call-method call-next-method
630 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
631 asin acos atan sinh cosh tanh asinh acosh atanh float random
632 truncate floor ceiling round minusp zerop plusp evenp oddp
633 < <= = /= >= > > ;; complex
634 conjugate realpart imagpart phase
635 min max logand logior logxor lognot ffloor fceiling
636 ftruncate fround signum cis
640 (defpackage :lisp-stat-unittests
643 :lisp-stat
:lisp-stat-data-examples
)
644 (:shadowing-import-from
:lisp-stat
645 call-method call-next-method
;; objects
646 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
;; lsmath
647 asin acos atan sinh cosh tanh asinh acosh atanh float random
648 truncate floor ceiling round minusp zerop plusp evenp oddp
649 < <= = /= >= > ;; complex
650 conjugate realpart imagpart phase
651 min max logand logior logxor lognot ffloor fceiling
652 ftruncate fround signum cis
)
653 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard
; exec
654 almost
= almost
=lists numerical
=)) ; compare
656 (defpackage :cls-dataframe-example
658 :lift
:lisp-stat-unittests
659 :lisp-stat-data-examples
661 (:export absorbtion aluminum iron
))
664 (defpackage :lisp-stat-optimize
669 :lisp-stat-object-system
671 :lisp-stat-compound-data
677 :lisp-stat-linalg-data
681 (:shadowing-import-from
:lisp-stat-object-system
682 call-method call-next-method
)
683 (:shadowing-import-from
:lisp-stat-math
684 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
685 asin acos atan sinh cosh tanh asinh acosh atanh float random
686 truncate floor ceiling round minusp zerop plusp evenp oddp
687 < <= = /= >= > complex conjugate realpart imagpart phase
688 min max logand logior logxor lognot ffloor fceiling
689 ftruncate fround signum cis
)
695 newtonmax nelmeadmax
))