3 ;;; Time-stamp: <2009-12-22 22:38:17 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
*
39 *cls-data-dir
* *cls-home-dir
* *cls-examples-dir
*))
41 (defpackage :lisp-stat-object-system
42 (:nicknames
:ls-objects
:lsos
)
44 (:shadow
:call-method
:call-next-method
)
45 (:export ls-object objectp
*object
* kind-of-p make-object
47 *set-slot-hook
* proto-slot-value self
48 send call-next-method call-method
49 defmeth defproto instance-slots proto-name
))
51 ;;; -types and -float probably ought to be moved into a -numerics
54 (defpackage :lisp-stat-types
55 (:documentation
"Provides some typeing for LispStat, but is clearly
59 check-nonneg-fixnum check-one-nonneg-fixnum
60 check-one-fixnum check-one-real check-one-number
))
62 (defpackage :lisp-stat-float
64 (:export
+stat-float-typing
+ +stat-cfloat-typing
+ +stat-float-template
+
65 machine-epsilon base-float makedouble
67 make-base-trans-fun-2 make-base-trans-fun
69 base-log base-exp base-expt base-sqrt base-sin base-cos
70 base-tan base-asin base-acos base-atan base-sinh
71 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
72 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
73 BASE-FROUND BASE-SIGNUM BASE-CIS
))
75 ;;; Probably should move into cls-data package.
77 (defpackage :lisp-stat-compound-data
79 :lisp-stat-object-system
81 (:shadowing-import-from
:lisp-stat-object-system
82 call-next-method call-method
)
83 (:export compound-data-p
*compound-data-proto
*
85 compound-data-seq compound-data-length
86 element-list element-seq
88 recursive-map-elements map-elements repeat
90 get-next-element make-next-element set-next-element
93 select split-list which
97 (defpackage :lisp-stat-macros
99 :lisp-stat-compound-data
)
100 (:export make-rv-function make-rv-function-1
))
102 (defpackage :lisp-stat-basics
104 :lisp-stat-object-system
108 :lisp-stat-compound-data
)
109 (:shadowing-import-from
:lisp-stat-object-system
110 call-method call-next-method
)
111 (:export permute-array sum prod count-elements mean
114 (defpackage :lisp-stat-float
116 (:export
+stat-float-typing
+ +stat-cfloat-typing
+ +stat-float-template
+
117 machine-epsilon base-float makedouble
119 make-base-trans-fun-2 make-base-trans-fun
121 BASE-LOG BASE-EXP BASE-EXPT BASE-SQRT BASE-SIN BASE-COS
122 BASE-TAN BASE-ASIN BASE-ACOS BASE-ATAN BASE-SINH
123 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
124 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
125 BASE-FROUND BASE-SIGNUM BASE-CIS
))
127 (defpackage :lisp-stat-macros
129 :lisp-stat-compound-data
)
130 (:export make-rv-function make-rv-function-1
))
133 (defpackage :cls-matrix
134 (:documentation
"basic utilities for using lisp arrays as numerical
135 matrices. Not optimized, and must consider this slow. Routines
136 should be optimized, it is only that we need them first, optimize
139 (:export matrixp num-rows num-cols matmult identity-matrix diagonal
140 row-list column-list inner-product outer-product
141 cross-product transpose bind-columns bind-rows
142 array-data-vector vector-to-array
))
145 ;;; NEW CLOS STRUCTURE
147 ;; CLS-DATA contains the basic variable structure, classes, support/indexing, and mixins.
148 ;; CLS-DATAFRAME leverages CLS-DATA, XARRAY, and LISP-MATRIX
149 ;; CLS-DATAIO stores/saves structures
150 ;; CLS-DATATRANS converts between structures, and from DATAFRAMES to MODEL-MATRIXES
152 (defpackage :cls-data
154 (:shadowing-import-from
:xarray slice
)
159 ;;; cls-data... in dataframe, though.
160 (defpackage :cls-dataframe
165 (:shadowing-import-from
:xarray slice
)
167 ;; generic container class for data -- if small enough
168 ;; could be value, otherwise might be reference.
174 list-of-columns
;; list-of-variables
175 list-of-rows
;; list-of-observations
178 varlabels caselabels nrows ncols
179 dataframe-dimension dataframe-dimensons
180 xref xtype xdims xdim xrank slice take carray
185 (defpackage :cls-dataio
186 (:documentation
"Data I/O and similar import technologies.")
188 :lisp-stat-object-system
192 (:shadowing-import-from
:lisp-stat-object-system
193 call-method call-next-method
)
194 (:export dsvstream-
>dataframe dsvstream-
>matrix dsvstream-
>listoflist
))
196 (defpackage :cls-datatrans
197 (:documentation
"Data I/O and similar import technologies.")
199 :lisp-stat-object-system
203 (:shadowing-import-from
:lisp-stat-object-system
204 call-method call-next-method
)
205 (:export dsvstream-
>dataframe dsvstream-
>matrix dsvstream-
>listoflist
207 listoflist-
>dataframe
209 listoflist-
>matrix-like
210 filename.dsv-
>dataframe
))
214 (defpackage :lisp-stat-model
215 (:documentation
"Model management for data analysis.")
219 ;; data structures for model and model/data combination
220 model statistical-model analysis
))
224 (defpackage :cls-visualize
228 (:shadowing-import-from
:xarray slice
)
232 (defpackage :cls-visualize-plplot
239 plot-ex contour-plot-ex fn-contour-plot-ex shade-plot-ex
3D-plot-ex
))
244 (defpackage :lisp-stat-ffi-int
247 (:export ccl-store-integer ccl-store-double ccl-store-ptr
250 (defpackage :lisp-stat-probability
255 (:export log-gamma set-seed
257 normal-cdf normal-quant normal-dens normal-rand
259 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
260 gamma-cdf gamma-quant gamma-dens gamma-rand
261 chisq-cdf chisq-quant chisq-dens chisq-rand
262 beta-cdf beta-quant beta-dens beta-rand
263 t-cdf t-quant t-dens t-rand
264 f-cdf f-quant f-dens f-rand
265 poisson-cdf poisson-quant poisson-pmf poisson-rand
266 binomial-cdf binomial-quant binomial-pmf binomial-rand
))
270 (defpackage :lisp-stat-math
272 :lisp-stat-object-system
274 :lisp-stat-compound-data
276 (:shadowing-import-from
:lisp-stat-object-system
277 call-method call-next-method
)
278 (:shadow expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
279 asin acos atan sinh cosh tanh asinh acosh atanh float random
280 truncate floor ceiling round minusp zerop plusp evenp oddp
281 < <= = /= >= > ;; complex
282 conjugate realpart imagpart phase
283 min max logand logior logxor lognot ffloor fceiling
284 ftruncate fround signum cis
)
285 (:export ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
286 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
287 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
289 conjugate realpart imagpart phase min max
290 logand logior logxor lognot ffloor fceiling ftruncate fround
292 (:documentation
"Vectorization of numerical functions"))
295 #|
;; some of this goes back in, but not all of it?
296 (defpackage :lisp-stat-linalg
303 :lisp-stat-compound-data
)
304 (:shadowing-import-from
:lisp-stat-math
305 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
306 asin acos atan sinh cosh tanh asinh acosh atanh float random
307 truncate floor ceiling round minusp zerop plusp evenp oddp
308 < <= = /= >= > complex conjugate realpart imagpart phase
309 min max logand logior logxor lognot ffloor fceiling
310 ftruncate fround signum cis
)
311 (:export chol-decomp lu-decomp lu-solve determinant inverse
312 sv-decomp qr-decomp rcondest make-rotation spline
313 kernel-dens kernel-smooth
314 fft make-sweep-matrix sweep-operator ax
+y eigen
316 check-real
;; for optimize
318 covariance-matrix matrix print-matrix solve
319 backsolve eigenvalues eigenvectors accumulate cumsum combine
327 (defpackage :lisp-stat-data
328 (:documentation
"Data management, integration, I/O, and other data technologies.")
329 (:nicknames
:ls-data
)
331 :lisp-stat-object-system
334 :lisp-stat-compound-data
)
335 (:shadowing-import-from
:lisp-stat-object-system
336 call-method call-next-method
)
338 ;; generic structures
340 empirical-statistical-variable
341 modelbased-statistical-variable
342 categorical-statistical-variable
343 nominal-statistical-variable
344 ordinal-statistical-variable
345 continuous-statistical-variable
347 ordering factor-levels nobs support pdmf draw
351 statistical-observation
352 measurement-types record
354 open-file-dialog read-data-file read-data-columns load-data
355 load-example
*variables
* *ask-on-redefine
*
356 def variables savevar undef
))
358 (defpackage :lisp-stat-descriptive-statistics
363 :lisp-stat-compound-data
365 (:shadowing-import-from
:lisp-stat-math
;; life is a vector!
366 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
367 asin acos atan sinh cosh tanh asinh acosh atanh float random
368 truncate floor ceiling round minusp zerop plusp evenp oddp
369 < <= = /= >= > ;; complex
370 conjugate realpart imagpart phase
371 min max logand logior logxor lognot ffloor fceiling
372 ftruncate fround signum cis
)
373 (:export mean standard-deviation variance
374 quantile median interquartile-range
377 (defpackage :lisp-stat-regression-linear
381 :lisp-stat-compound-data
382 :lisp-stat-descriptive-statistics
)
383 (:shadowing-import-from
:lisp-stat-object-system
384 call-method call-next-method
)
385 (:export regression-model fit-model
387 estimates covariance-matrix
388 ;; functions for helpers
390 print-object
;; for method dispatch
393 (defpackage :common-lisp-statistics
394 (:documentation
"Experimentation package for LispStat. Serious work
395 should be packaged up as a separate but similar package to help
396 drive reproducibility. By this I mean, creating a
397 data/analytics/analysis package with the minimal set of
398 objects/packages required.")
399 (:nicknames
:cls
:common-lisp-statistics
:lisp-stat
)
401 :xarray
;; generic reference -- internally supporting array, lol structs
403 :lisp-matrix
;; conversion to a more robust linalg approach
405 :lisp-stat-object-system
406 :lisp-stat-compound-data
407 :lisp-stat-probability
415 :lisp-stat-descriptive-statistics
416 :lisp-stat-regression-linear
419 ;; :cls-visualize-plplot
421 (:shadowing-import-from
:xarray slice
)
422 (:shadowing-import-from
:lisp-stat-object-system
423 call-method call-next-method
)
424 (:shadowing-import-from
:lisp-stat-math
425 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
426 asin acos atan sinh cosh tanh asinh acosh atanh float random
427 truncate floor ceiling round minusp zerop plusp evenp oddp
430 conjugate realpart imagpart phase
433 logand logior logxor lognot
434 ffloor fceiling ftruncate fround
438 *default-path
* *lsos-files
* *basic-files
* *ls-files
*
439 l
*cls-home-dir
* *cls-data-dir
* *cls-examples-dir
*
443 defmeth send proto-slot-value
446 fixnump check-nonneg-fixnum check-one-fixnum
447 check-one-nonneg-fixnum
448 check-one-real check-one-number
456 compound-data-p
*compound-data-proto
* compound-object-p
457 compound-data-seq compound-data-length
458 element-list element-seq
460 recursive-map-elements map-elements
463 get-next-element make-next-element set-next-element
471 ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
472 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
473 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
475 conjugate realpart imagpart phase min max
476 logand logior logxor lognot ffloor fceiling ftruncate fround
479 #|
;; The following need to be re-found in lisp-matrix...
482 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
483 column-list inner-product outer-product cross-product transpose
484 bind-columns bind-rows
487 chol-decomp lu-decomp lu-solve determinant inverse
488 sv-decomp qr-decomp rcondest make-rotation spline
489 kernel-dens kernel-smooth
490 fft make-sweep-matrix sweep-operator ax
+y eigen
492 covariance-matrix matrix print-matrix solve
493 backsolve eigenvalues eigenvectors accumulate cumsum combine
496 ;; in linalg.lisp, possibly not supported by matlisp
497 spline kernel-dens kernel-smooth
505 make-rv-function make-rv-function-1
508 xref xtype xdims xdim xdims
*
511 sublists-of-same-size-p equal-listoflist transpose-listoflist
514 ;; need to take this list and make it strings... specs could mean
515 ;; that we process the strings in different ways?
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
535 listoflist-
>dataframe listoflist-
>array listoflist-
>matrix-like
537 ;; statistics.lsp (descriptions, should probably be moved
539 standard-deviation quantile median interquartile-range
542 ;; probability (dists.lisp)
544 uniform-rand normal-cdf normal-quant normal-dens
545 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
546 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
547 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
548 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
549 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
550 binomial-cdf binomial-quant binomial-pmf binomial-rand
552 ;; Here is where we have a problem -- lispstat core should be core
553 ;; data management and config problems, with packages providing
554 ;; specialized extensions to LispStat, i.e. regression, nonlin
555 ;; regression, bayesian regression via laplace approximation, etc.
557 ;; The following could be considered "recommended packages",
558 ;; similar to the idea of the recommended packages in R. Probably
559 ;; we want them to do the exporting within that package, therefore
560 ;; NOT being able to lock the "data-ish" package, but only the
561 ;; subpackages prior to export.
564 ;; -- linear regressin models.
565 regression-model fit-model
566 estimates covariance-matrix
568 regression-model-proto x y intercept sweep-matrix
569 basis weights included total-sum-of-squares residual-sum-of-squares
570 predictor-names response-name case-labels
574 ;; -- nonlinear regression models
575 nreg-model nreg-model-proto mean-function theta-hat epsilon
577 ;; we might need something like xtxinv here? But should be
578 ;; encapsulated, so we use the one in regression.lisp
581 bayes-model bayes-model-proto bayes-internals
593 ;;;; PACKAGES FOR USEABILITY
595 (defpackage :lisp-stat-data-examples
596 (:documentation
"Example data for unittests, examples, illustrations,")
598 :common-lisp-statistics
)
599 (:shadowing-import-from
:lisp-stat
600 call-method call-next-method
602 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
603 asin acos atan sinh cosh tanh asinh acosh atanh float random
604 truncate floor ceiling round minusp zerop plusp evenp oddp
605 < <= = /= >= > > ;; complex
606 conjugate realpart imagpart phase
607 min max logand logior logxor lognot ffloor fceiling
608 ftruncate fround signum cis
611 (:export iron aluminum absorbtion
615 (defpackage :lisp-stat-user
616 (:documentation
"Experimentation package for LispStat. Serious work
617 should be placed in a similar package elsewhere for
618 reproducibility. But this should hint as to what needs to be done
619 for a user- or analysis-package.")
620 (:nicknames
:ls-user
:cls-user
)
621 (:use
:common-lisp
; always needed for user playgrounds!
623 :common-lisp-statistics
624 :lisp-stat-data-examples
) ;; this last is to have 'things to play with'
625 (:shadowing-import-from
:lisp-stat
626 call-method call-next-method
628 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
629 asin acos atan sinh cosh tanh asinh acosh atanh float random
630 truncate floor ceiling round minusp zerop plusp evenp oddp
631 < <= = /= >= > > ;; complex
632 conjugate realpart imagpart phase
633 min max logand logior logxor lognot ffloor fceiling
634 ftruncate fround signum cis
638 (defpackage :lisp-stat-unittests
641 :lisp-stat
:lisp-stat-data-examples
)
642 (:shadowing-import-from
:lisp-stat
643 call-method call-next-method
;; objects
644 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
;; lsmath
645 asin acos atan sinh cosh tanh asinh acosh atanh float random
646 truncate floor ceiling round minusp zerop plusp evenp oddp
647 < <= = /= >= > ;; complex
648 conjugate realpart imagpart phase
649 min max logand logior logxor lognot ffloor fceiling
650 ftruncate fround signum cis
)
651 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard
; exec
652 almost
= almost
=lists numerical
=)) ; compare
654 (defpackage :cls-dataframe-example
656 :lift
:lisp-stat-unittests
657 :lisp-stat-data-examples
659 (:export absorbtion aluminum iron
))
662 (defpackage :lisp-stat-optimize
667 :lisp-stat-object-system
669 :lisp-stat-compound-data
675 :lisp-stat-linalg-data
679 (:shadowing-import-from
:lisp-stat-object-system
680 call-method call-next-method
)
681 (:shadowing-import-from
:lisp-stat-math
682 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
683 asin acos atan sinh cosh tanh asinh acosh atanh float random
684 truncate floor ceiling round minusp zerop plusp evenp oddp
685 < <= = /= >= > complex conjugate realpart imagpart phase
686 min max logand logior logxor lognot ffloor fceiling
687 ftruncate fround signum cis
)
693 newtonmax nelmeadmax
))