3 ;;; Time-stamp: <2009-10-30 08:17:46 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
)
33 (defpackage :lisp-stat-object-system
34 (:nicknames
:ls-objects
:lsos
)
36 (:shadow
:call-method
:call-next-method
)
37 (:export ls-object objectp
*object
* kind-of-p make-object
39 *set-slot-hook
* proto-slot-value self
40 send call-next-method call-method
41 defmeth defproto instance-slots proto-name
))
43 ;;; -types and -float probably ought to be moved into a -numerics
46 (defpackage :lisp-stat-types
47 (:documentation
"Provides some typeing for LispStat, but is clearly
51 check-nonneg-fixnum check-one-nonneg-fixnum
52 check-one-fixnum check-one-real check-one-number
))
54 (defpackage :lisp-stat-float
56 (:export
+stat-float-typing
+ +stat-cfloat-typing
+ +stat-float-template
+
57 machine-epsilon base-float makedouble
59 make-base-trans-fun-2 make-base-trans-fun
61 base-log base-exp base-expt base-sqrt base-sin base-cos
62 base-tan base-asin base-acos base-atan base-sinh
63 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
64 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
65 BASE-FROUND BASE-SIGNUM BASE-CIS
))
67 ;;; Probably should move into cls-data package.
69 (defpackage :lisp-stat-compound-data
71 :lisp-stat-object-system
73 (:shadowing-import-from
:lisp-stat-object-system
74 call-next-method call-method
)
75 (:export compound-data-p
*compound-data-proto
*
77 compound-data-seq compound-data-length
78 element-list element-seq
80 recursive-map-elements map-elements repeat
82 get-next-element make-next-element set-next-element
85 select split-list which
89 (defpackage :lisp-stat-macros
91 :lisp-stat-compound-data
)
92 (:export make-rv-function make-rv-function-1
))
94 (defpackage :lisp-stat-basics
96 :lisp-stat-object-system
100 :lisp-stat-compound-data
)
101 (:shadowing-import-from
:lisp-stat-object-system
102 call-method call-next-method
)
103 (:export permute-array sum prod count-elements mean
106 (defpackage :lisp-stat-float
108 (:export
+stat-float-typing
+ +stat-cfloat-typing
+ +stat-float-template
+
109 machine-epsilon base-float makedouble
111 make-base-trans-fun-2 make-base-trans-fun
113 BASE-LOG BASE-EXP BASE-EXPT BASE-SQRT BASE-SIN BASE-COS
114 BASE-TAN BASE-ASIN BASE-ACOS BASE-ATAN BASE-SINH
115 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
116 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
117 BASE-FROUND BASE-SIGNUM BASE-CIS
))
119 (defpackage :lisp-stat-macros
121 :lisp-stat-compound-data
)
122 (:export make-rv-function make-rv-function-1
))
125 (defpackage :cls-matrix
126 (:documentation
"basic utilities for using lisp arrays as numerical
127 matrices. Not optimized, and must consider this slow. Routines
128 should be optimized, it is only that we need them first, optimize
131 (:export matrixp num-rows num-cols matmult identity-matrix diagonal
132 row-list column-list inner-product outer-product
133 cross-product transpose bind-columns bind-rows
134 array-data-vector vector-to-array
))
137 ;;; NEW CLOS STRUCTURE
139 ;;; cls-data... in dataframe, though.
140 (defpackage :cls-dataframe
144 (:shadowing-import-from
:xarray slice
)
146 ;; generic container class for data -- if small enough
147 ;; could be value, otherwise might be reference.
153 varlabels caselabels nrows ncols
154 dataframe-dimension dataframe-dimensons
155 xref xtype xdims xdim xrank slice take carray
157 dfref dfref-case dfref-var
158 consistent-dataframe-p
162 list-of-columns
;; list-of-variables
163 list-of-rows
;; list-of-observations
166 (defpackage :cls-data
170 :cls-dataframe
) ; for dataframe
171 (:shadowing-import-from
:xarray slice
)
172 (:export listoflist-
>dataframe
174 listoflist-
>matrix-like
))
181 (defpackage :cls-dataimport
182 (:documentation
"Data I/O and similar import technologies.")
184 :lisp-stat-object-system
188 (:shadowing-import-from
:lisp-stat-object-system
189 call-method call-next-method
)
190 (:export dsvstream-
>dataframe dsvstream-
>matrix dsvstream-
>listoflist
))
193 (defpackage :lisp-stat-model
194 (:documentation
"Model management for data analysis.")
198 ;; data structures for model and model/data combination
199 model statistical-model analysis
))
203 (defpackage :cls-visualize
207 (:shadowing-import-from
:xarray slice
)
211 (defpackage :cls-visualize-plplot
218 plot-ex contour-plot-ex fn-contour-plot-ex shade-plot-ex
3D-plot-ex
))
223 (defpackage :lisp-stat-ffi-int
226 (:export ccl-store-integer ccl-store-double ccl-store-ptr
229 (defpackage :lisp-stat-probability
234 (:export log-gamma set-seed
236 normal-cdf normal-quant normal-dens normal-rand
238 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
239 gamma-cdf gamma-quant gamma-dens gamma-rand
240 chisq-cdf chisq-quant chisq-dens chisq-rand
241 beta-cdf beta-quant beta-dens beta-rand
242 t-cdf t-quant t-dens t-rand
243 f-cdf f-quant f-dens f-rand
244 poisson-cdf poisson-quant poisson-pmf poisson-rand
245 binomial-cdf binomial-quant binomial-pmf binomial-rand
))
249 (defpackage :lisp-stat-math
251 :lisp-stat-object-system
253 :lisp-stat-compound-data
255 (:shadowing-import-from
:lisp-stat-object-system
256 call-method call-next-method
)
257 (:shadow expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
258 asin acos atan sinh cosh tanh asinh acosh atanh float random
259 truncate floor ceiling round minusp zerop plusp evenp oddp
260 < <= = /= >= > ;; complex
261 conjugate realpart imagpart phase
262 min max logand logior logxor lognot ffloor fceiling
263 ftruncate fround signum cis
)
264 (:export ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
265 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
266 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
268 conjugate realpart imagpart phase min max
269 logand logior logxor lognot ffloor fceiling ftruncate fround
271 (:documentation
"Vectorization of numerical functions"))
274 #|
;; some of this goes back in, but not all of it?
275 (defpackage :lisp-stat-linalg
282 :lisp-stat-compound-data
)
283 (:shadowing-import-from
:lisp-stat-math
284 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
285 asin acos atan sinh cosh tanh asinh acosh atanh float random
286 truncate floor ceiling round minusp zerop plusp evenp oddp
287 < <= = /= >= > complex conjugate realpart imagpart phase
288 min max logand logior logxor lognot ffloor fceiling
289 ftruncate fround signum cis
)
290 (:export chol-decomp lu-decomp lu-solve determinant inverse
291 sv-decomp qr-decomp rcondest make-rotation spline
292 kernel-dens kernel-smooth
293 fft make-sweep-matrix sweep-operator ax
+y eigen
295 check-real
;; for optimize
297 covariance-matrix matrix print-matrix solve
298 backsolve eigenvalues eigenvectors accumulate cumsum combine
306 (defpackage :lisp-stat-data
307 (:documentation
"Data management, integration, I/O, and other data technologies.")
308 (:nicknames
:ls-data
)
310 :lisp-stat-object-system
313 :lisp-stat-compound-data
)
314 (:shadowing-import-from
:lisp-stat-object-system
315 call-method call-next-method
)
317 ;; generic structures
319 empirical-statistical-variable
320 modelbased-statistical-variable
321 categorical-statistical-variable
322 nominal-statistical-variable
323 ordinal-statistical-variable
324 continuous-statistical-variable
326 ordering factor-levels nobs support pdmf draw
330 statistical-observation
331 measurement-types record
333 open-file-dialog read-data-file read-data-columns load-data
334 load-example
*variables
* *ask-on-redefine
*
335 def variables savevar undef
))
337 (defpackage :lisp-stat-descriptive-statistics
342 :lisp-stat-compound-data
344 (:shadowing-import-from
:lisp-stat-math
;; life is a vector!
345 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
346 asin acos atan sinh cosh tanh asinh acosh atanh float random
347 truncate floor ceiling round minusp zerop plusp evenp oddp
348 < <= = /= >= > ;; complex
349 conjugate realpart imagpart phase
350 min max logand logior logxor lognot ffloor fceiling
351 ftruncate fround signum cis
)
352 (:export mean standard-deviation variance
353 quantile median interquartile-range
356 (defpackage :lisp-stat-regression-linear
360 :lisp-stat-compound-data
361 :lisp-stat-descriptive-statistics
)
362 (:shadowing-import-from
:lisp-stat-object-system
363 call-method call-next-method
)
364 (:export regression-model fit-model
366 estimates covariance-matrix
367 ;; functions for helpers
369 print-object
;; for method dispatch
372 (defpackage :common-lisp-statistics
373 (:documentation
"Experimentation package for LispStat. Serious work
374 should be packaged up as a separate but similar package to help
375 drive reproducibility. By this I mean, creating a
376 data/analytics/analysis package with the minimal set of
377 objects/packages required.")
378 (:nicknames
:cls
:common-lisp-statistics
:lisp-stat
)
380 :xarray
;; generic reference -- internally supporting array, lol structs
381 :lisp-matrix
;; conversion to a more robust linalg approach
383 :lisp-stat-object-system
384 :lisp-stat-compound-data
385 :lisp-stat-probability
393 :lisp-stat-descriptive-statistics
394 :lisp-stat-regression-linear
397 ;; :cls-visualize-plplot
399 (:shadowing-import-from
:xarray slice
)
400 (:shadowing-import-from
:lisp-stat-object-system
401 call-method call-next-method
)
402 (:shadowing-import-from
:lisp-stat-math
403 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
404 asin acos atan sinh cosh tanh asinh acosh atanh float random
405 truncate floor ceiling round minusp zerop plusp evenp oddp
408 conjugate realpart imagpart phase
411 logand logior logxor lognot
412 ffloor fceiling ftruncate fround
416 *default-path
* *lsos-files
* *basic-files
* *ls-files
*
417 *lispstat-home-dir
* *lispstat-data-dir
* *lispstat-examples-dir
*
421 defmeth send proto-slot-value
424 fixnump check-nonneg-fixnum check-one-fixnum
425 check-one-nonneg-fixnum
426 check-one-real check-one-number
434 compound-data-p
*compound-data-proto
* compound-object-p
435 compound-data-seq compound-data-length
436 element-list element-seq
438 recursive-map-elements map-elements
441 get-next-element make-next-element set-next-element
449 ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
450 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
451 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
453 conjugate realpart imagpart phase min max
454 logand logior logxor lognot ffloor fceiling ftruncate fround
457 #|
;; The following need to be re-found in lisp-matrix...
460 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
461 column-list inner-product outer-product cross-product transpose
462 bind-columns bind-rows
465 chol-decomp lu-decomp lu-solve determinant inverse
466 sv-decomp qr-decomp rcondest make-rotation spline
467 kernel-dens kernel-smooth
468 fft make-sweep-matrix sweep-operator ax
+y eigen
470 covariance-matrix matrix print-matrix solve
471 backsolve eigenvalues eigenvectors accumulate cumsum combine
474 ;; in linalg.lisp, possibly not supported by matlisp
475 spline kernel-dens kernel-smooth
483 make-rv-function make-rv-function-1
486 xref xtype xdims xdim xdims
*
487 lists-of-same-size equal-listoflist transpose-listoflist
490 ;; need to take this list and make it strings... specs could mean
491 ;; that we process the strings in different ways?
495 (mapc #'symbol-for-symbol-to-string-or-symbol
496 (do-external-symbols (s (find-package 'lisp-stat-data
) lst
) (push s lst
))))
499 open-file-dialog read-data-file read-data-columns load-data
500 load-example
*variables
* *ask-on-redefine
*
501 def variables savevar undef
503 dataframe-like dataframe-array make-dataframe
504 varlabels caselabels nrows ncols
505 dataframe-dimension dataframe-dimensons
506 dfref dfref-case dfref-var
507 consistent-dataframe-p
508 dataset list-of-columns list-of-rows
511 listoflist-
>dataframe listoflist-
>array listoflist-
>matrix-like
513 ;; statistics.lsp (descriptions, should probably be moved
515 standard-deviation quantile median interquartile-range
518 ;; probability (dists.lisp)
520 uniform-rand normal-cdf normal-quant normal-dens
521 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
522 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
523 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
524 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
525 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
526 binomial-cdf binomial-quant binomial-pmf binomial-rand
528 ;; Here is where we have a problem -- lispstat core should be core
529 ;; data management and config problems, with packages providing
530 ;; specialized extensions to LispStat, i.e. regression, nonlin
531 ;; regression, bayesian regression via laplace approximation, etc.
533 ;; The following could be considered "recommended packages",
534 ;; similar to the idea of the recommended packages in R. Probably
535 ;; we want them to do the exporting within that package, therefore
536 ;; NOT being able to lock the "data-ish" package, but only the
537 ;; subpackages prior to export.
540 ;; -- linear regressin models.
541 regression-model fit-model
542 estimates covariance-matrix
544 regression-model-proto x y intercept sweep-matrix
545 basis weights included total-sum-of-squares residual-sum-of-squares
546 predictor-names response-name case-labels
550 ;; -- nonlinear regression models
551 nreg-model nreg-model-proto mean-function theta-hat epsilon
553 ;; we might need something like xtxinv here? But should be
554 ;; encapsulated, so we use the one in regression.lisp
557 bayes-model bayes-model-proto bayes-internals
569 ;;;; PACKAGES FOR USEABILITY
571 (defpackage :lisp-stat-data-examples
572 (:documentation
"Example data for unittests, examples, illustrations,")
574 :common-lisp-statistics
)
575 (:shadowing-import-from
:lisp-stat
576 call-method call-next-method
578 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
579 asin acos atan sinh cosh tanh asinh acosh atanh float random
580 truncate floor ceiling round minusp zerop plusp evenp oddp
581 < <= = /= >= > > ;; complex
582 conjugate realpart imagpart phase
583 min max logand logior logxor lognot ffloor fceiling
584 ftruncate fround signum cis
587 (:export iron aluminum absorbtion
591 (defpackage :lisp-stat-user
592 (:documentation
"Experimentation package for LispStat. Serious work
593 should be placed in a similar package elsewhere for
594 reproducibility. But this should hint as to what needs to be done
595 for a user- or analysis-package.")
596 (:nicknames
:ls-user
)
597 (:use
:common-lisp
; always needed for user playgrounds!
599 :common-lisp-statistics
600 :lisp-stat-data-examples
) ;; this last is to have 'things to play with'
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
614 (defpackage :lisp-stat-unittests
617 :lisp-stat
:lisp-stat-data-examples
)
618 (:shadowing-import-from
:lisp-stat
619 call-method call-next-method
;; objects
620 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
;; lsmath
621 asin acos atan sinh cosh tanh asinh acosh atanh float random
622 truncate floor ceiling round minusp zerop plusp evenp oddp
623 < <= = /= >= > ;; complex
624 conjugate realpart imagpart phase
625 min max logand logior logxor lognot ffloor fceiling
626 ftruncate fround signum cis
)
627 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard
; exec
628 almost
= almost
=lists numerical
=)) ; compare
630 (defpackage :cls-dataframe-example
632 :lift
:lisp-stat-unittests
633 :lisp-stat-data-examples
635 (:export absorbtion aluminum iron
))
638 (defpackage :lisp-stat-optimize
643 :lisp-stat-object-system
645 :lisp-stat-compound-data
651 :lisp-stat-linalg-data
655 (:shadowing-import-from
:lisp-stat-object-system
656 call-method call-next-method
)
657 (:shadowing-import-from
:lisp-stat-math
658 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
659 asin acos atan sinh cosh tanh asinh acosh atanh float random
660 truncate floor ceiling round minusp zerop plusp evenp oddp
661 < <= = /= >= > complex conjugate realpart imagpart phase
662 min max logand logior logxor lognot ffloor fceiling
663 ftruncate fround signum cis
)
669 newtonmax nelmeadmax
))