3 ;;; Time-stamp: <2009-07-18 12:58:33 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.
20 (defpackage :lisp-stat-object-system
21 (:nicknames
:ls-objects
:lsos
)
23 (:shadow
:call-method
:call-next-method
)
24 (:export ls-object objectp
*object
* kind-of-p make-object
26 *set-slot-hook
* proto-slot-value self
27 send call-next-method call-method
28 defmeth defproto instance-slots proto-name
))
30 ;;; -types and -float probably ought to be moved into a -numerics
33 (defpackage :lisp-stat-types
34 (:documentation
"Provides some typeing for LispStat, but is clearly
38 check-nonneg-fixnum check-one-nonneg-fixnum
39 check-one-fixnum check-one-real check-one-number
))
41 (defpackage :lisp-stat-float
43 (:export
+stat-float-typing
+ +stat-cfloat-typing
+ +stat-float-template
+
44 machine-epsilon base-float makedouble
46 make-base-trans-fun-2 make-base-trans-fun
48 base-log base-exp base-expt base-sqrt base-sin base-cos
49 base-tan base-asin base-acos base-atan base-sinh
50 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
51 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
52 BASE-FROUND BASE-SIGNUM BASE-CIS
))
54 ;;; Probably should move into cls-data package.
56 (defpackage :lisp-stat-compound-data
58 :lisp-stat-object-system
60 (:shadowing-import-from
:lisp-stat-object-system
61 call-next-method call-method
)
62 (:export compound-data-p
*compound-data-proto
*
64 compound-data-seq compound-data-length
65 element-list element-seq
67 recursive-map-elements map-elements repeat
69 get-next-element make-next-element set-next-element
72 select split-list which
76 (defpackage :lisp-stat-macros
78 :lisp-stat-compound-data
)
79 (:export make-rv-function make-rv-function-1
))
81 (defpackage :lisp-stat-basics
83 :lisp-stat-object-system
87 :lisp-stat-compound-data
)
88 (:shadowing-import-from
:lisp-stat-object-system
89 call-method call-next-method
)
90 (:export permute-array sum prod count-elements mean
93 (defpackage :lisp-stat-float
95 (:export
+stat-float-typing
+ +stat-cfloat-typing
+ +stat-float-template
+
96 machine-epsilon base-float makedouble
98 make-base-trans-fun-2 make-base-trans-fun
100 BASE-LOG BASE-EXP BASE-EXPT BASE-SQRT BASE-SIN BASE-COS
101 BASE-TAN BASE-ASIN BASE-ACOS BASE-ATAN BASE-SINH
102 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
103 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
104 BASE-FROUND BASE-SIGNUM BASE-CIS
))
106 (defpackage :lisp-stat-macros
108 :lisp-stat-compound-data
)
109 (:export make-rv-function make-rv-function-1
))
112 (defpackage :cls-matrix
113 (:documentation
"basic utilities for using lisp arrays as numerical
114 matrices. Not optimized, and must consider this slow. Routines
115 should be optimized, it is only that we need them first, optimize
118 (:export matrixp num-rows num-cols matmult identity-matrix diagonal
119 row-list column-list inner-product outer-product
120 cross-product transpose bind-columns bind-rows
121 array-data-vector vector-to-array
))
124 ;;; NEW CLOS STRUCTURE
126 ;;; cls-data... in dataframe, though.
127 (defpackage :cls-dataframe
132 ;; generic container class for data -- if small enough
133 ;; could be value, otherwise might be reference.
139 varlabels caselabels nrows ncols
140 dataframe-dimension dataframe-dimensons
141 xref xtype xdims xdim xrank slice take carray
143 dfref dfref-case dfref-var
144 consistent-dataframe-p
148 list-of-columns
;; list-of-variables
149 list-of-rows
;; list-of-observations
152 ;; move to cls-data -- but in listoflist.lisp
153 (defpackage :cls-data-listoflist
156 :cls-dataframe
) ; for dataframe
157 (:export lists-of-same-size
160 listoflist-
>dataframe
162 listoflist-
>matrix-like
))
165 (defpackage :cls-dataimport
166 (:documentation
"Data I/O and similar import technologies.")
168 :lisp-stat-object-system
172 (:shadowing-import-from
:lisp-stat-object-system
173 call-method call-next-method
)
174 (:export dsvstream-
>dataframe dsvstream-
>matrix dsvstream-
>listoflist
))
177 (defpackage :lisp-stat-model
178 (:documentation
"Model management for data analysis.")
182 ;; data structures for model and model/data combination
183 model statistical-model analysis
))
187 (defpackage :cls-visualize
193 (defpackage :cls-visualize-plplot
200 plot-ex contour-plot-ex fn-contour-plot-ex shade-plot-ex
3D-plot-ex
))
205 (defpackage :lisp-stat-ffi-int
208 (:export ccl-store-integer ccl-store-double ccl-store-ptr
211 (defpackage :lisp-stat-probability
216 (:export log-gamma set-seed
218 normal-cdf normal-quant normal-dens normal-rand
220 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
221 gamma-cdf gamma-quant gamma-dens gamma-rand
222 chisq-cdf chisq-quant chisq-dens chisq-rand
223 beta-cdf beta-quant beta-dens beta-rand
224 t-cdf t-quant t-dens t-rand
225 f-cdf f-quant f-dens f-rand
226 poisson-cdf poisson-quant poisson-pmf poisson-rand
227 binomial-cdf binomial-quant binomial-pmf binomial-rand
))
231 (defpackage :lisp-stat-math
233 :lisp-stat-object-system
235 :lisp-stat-compound-data
237 (:shadowing-import-from
:lisp-stat-object-system
238 call-method call-next-method
)
239 (:shadow expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
240 asin acos atan sinh cosh tanh asinh acosh atanh float random
241 truncate floor ceiling round minusp zerop plusp evenp oddp
242 < <= = /= >= > ;; complex
243 conjugate realpart imagpart phase
244 min max logand logior logxor lognot ffloor fceiling
245 ftruncate fround signum cis
)
246 (:export ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
247 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
248 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
250 conjugate realpart imagpart phase min max
251 logand logior logxor lognot ffloor fceiling ftruncate fround
253 (:documentation
"Vectorization of numerical functions"))
256 #|
;; some of this goes back in, but not all of it?
257 (defpackage :lisp-stat-linalg
264 :lisp-stat-compound-data
)
265 (:shadowing-import-from
:lisp-stat-math
266 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 conjugate realpart imagpart phase
270 min max logand logior logxor lognot ffloor fceiling
271 ftruncate fround signum cis
)
272 (:export chol-decomp lu-decomp lu-solve determinant inverse
273 sv-decomp qr-decomp rcondest make-rotation spline
274 kernel-dens kernel-smooth
275 fft make-sweep-matrix sweep-operator ax
+y eigen
277 check-real
;; for optimize
279 covariance-matrix matrix print-matrix solve
280 backsolve eigenvalues eigenvectors accumulate cumsum combine
288 (defpackage :lisp-stat-data
289 (:documentation
"Data management, integration, I/O, and other data technologies.")
290 (:nicknames
:ls-data
)
292 :lisp-stat-object-system
295 :lisp-stat-compound-data
)
296 (:shadowing-import-from
:lisp-stat-object-system
297 call-method call-next-method
)
298 (:export open-file-dialog read-data-file read-data-columns load-data
299 load-example
*variables
* *ask-on-redefine
*
300 def variables savevar undef
))
302 (defpackage :lisp-stat-descriptive-statistics
307 :lisp-stat-compound-data
309 (:shadowing-import-from
:lisp-stat-math
;; life is a vector!
310 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
311 asin acos atan sinh cosh tanh asinh acosh atanh float random
312 truncate floor ceiling round minusp zerop plusp evenp oddp
313 < <= = /= >= > ;; complex
314 conjugate realpart imagpart phase
315 min max logand logior logxor lognot ffloor fceiling
316 ftruncate fround signum cis
)
317 (:export mean standard-deviation variance
318 quantile median interquartile-range
321 (defpackage :lisp-stat-regression-linear
325 :lisp-stat-compound-data
326 :lisp-stat-descriptive-statistics
)
327 (:shadowing-import-from
:lisp-stat-object-system
328 call-method call-next-method
)
329 (:export regression-model fit-model
331 estimates covariance-matrix
332 ;; functions for helpers
334 print-object
;; for method dispatch
337 (defpackage :common-lisp-statistics
338 (:documentation
"Experimentation package for LispStat. Serious work
339 should be packaged up elsewhere for reproducibility. By this I
340 mean, creating a data/analytics/analysis package with the minimal
341 set of objects required.")
342 (:nicknames
:cls
:common-lisp-statistics
:lisp-stat
)
345 :lisp-stat-object-system
346 :lisp-stat-compound-data
347 :lisp-stat-probability
355 :lisp-matrix
;; conversion to a more robust linalg approach
356 :lisp-stat-descriptive-statistics
357 :lisp-stat-regression-linear
360 ;; :cls-visualize-plplot
362 (:shadowing-import-from
:lisp-stat-object-system
363 call-method call-next-method
)
364 (:shadowing-import-from
:lisp-stat-math
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
370 conjugate realpart imagpart phase
373 logand logior logxor lognot
374 ffloor fceiling ftruncate fround
378 *default-path
* *lsos-files
* *basic-files
* *ls-files
*
379 *lispstat-home-dir
* *lispstat-data-dir
* *lispstat-examples-dir
*
383 defmeth send proto-slot-value
386 fixnump check-nonneg-fixnum check-one-fixnum
387 check-one-nonneg-fixnum
388 check-one-real check-one-number
396 compound-data-p
*compound-data-proto
* compound-object-p
397 compound-data-seq compound-data-length
398 element-list element-seq
400 recursive-map-elements map-elements
403 get-next-element make-next-element set-next-element
411 ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
412 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
413 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
415 conjugate realpart imagpart phase min max
416 logand logior logxor lognot ffloor fceiling ftruncate fround
419 #|
;; The following need to be re-found in lisp-matrix...
422 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
423 column-list inner-product outer-product cross-product transpose
424 bind-columns bind-rows
427 chol-decomp lu-decomp lu-solve determinant inverse
428 sv-decomp qr-decomp rcondest make-rotation spline
429 kernel-dens kernel-smooth
430 fft make-sweep-matrix sweep-operator ax
+y eigen
432 covariance-matrix matrix print-matrix solve
433 backsolve eigenvalues eigenvectors accumulate cumsum combine
436 ;; in linalg.lisp, possibly not supported by matlisp
437 spline kernel-dens kernel-smooth
445 make-rv-function make-rv-function-1
448 xref xtype xdims xdim xdims
*
451 open-file-dialog read-data-file read-data-columns load-data
452 load-example
*variables
* *ask-on-redefine
*
453 def variables savevar undef
456 dataframe-like dataframe-array make-dataframe
457 varlabels caselabels nrows ncols
458 dataframe-dimension dataframe-dimensons
459 dfref dfref-case dfref-var
460 consistent-dataframe-p
461 dataset list-of-columns list-of-rows
464 lists-of-same-size equal-listoflist
466 listoflist-
>dataframe listoflist-
>array listoflist-
>matrix-like
468 ;; statistics.lsp (descriptions, should probably be moved
470 standard-deviation quantile median interquartile-range
473 ;; probability (dists.lisp)
475 uniform-rand normal-cdf normal-quant normal-dens
476 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
477 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
478 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
479 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
480 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
481 binomial-cdf binomial-quant binomial-pmf binomial-rand
483 ;; Here is where we have a problem -- lispstat core should be core
484 ;; data management and config problems, with packages providing
485 ;; specialized extensions to LispStat, i.e. regression, nonlin
486 ;; regression, bayesian regression via laplace approximation, etc.
488 ;; The following could be considered "recommended packages",
489 ;; similar to the idea of the recommended packages in R. Probably
490 ;; we want them to do the exporting within that package, therefore
491 ;; NOT being able to lock the "data-ish" package, but only the
492 ;; subpackages prior to export.
495 ;; -- linear regressin models.
496 regression-model fit-model
497 estimates covariance-matrix
499 regression-model-proto x y intercept sweep-matrix
500 basis weights included total-sum-of-squares residual-sum-of-squares
501 predictor-names response-name case-labels
505 ;; -- nonlinear regression models
506 nreg-model nreg-model-proto mean-function theta-hat epsilon
508 ;; we might need something like xtxinv here? But should be
509 ;; encapsulated, so we use the one in regression.lisp
512 bayes-model bayes-model-proto bayes-internals
524 ;;;; PACKAGES FOR USEABILITY
526 (defpackage :lisp-stat-data-examples
527 (:documentation
"Example data for unittests, examples, illustrations,")
529 :common-lisp-statistics
)
530 (:shadowing-import-from
:lisp-stat
531 call-method call-next-method
533 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
534 asin acos atan sinh cosh tanh asinh acosh atanh float random
535 truncate floor ceiling round minusp zerop plusp evenp oddp
536 < <= = /= >= > > ;; complex
537 conjugate realpart imagpart phase
538 min max logand logior logxor lognot ffloor fceiling
539 ftruncate fround signum cis
542 (:export iron aluminum absorbtion
546 (defpackage :lisp-stat-user
547 (:documentation
"Experimentation package for LispStat. Serious work
548 should be placed in a similar package elsewhere for
549 reproducibility. But this should hint as to what needs to be done
550 for a user- or analysis-package.")
551 (:nicknames
:ls-user
)
552 (:use
:common-lisp
; always needed for user playgrounds!
554 :common-lisp-statistics
555 :lisp-stat-data-examples
) ;; this last is to have 'things to play with'
556 (:shadowing-import-from
:lisp-stat
557 call-method call-next-method
559 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
560 asin acos atan sinh cosh tanh asinh acosh atanh float random
561 truncate floor ceiling round minusp zerop plusp evenp oddp
562 < <= = /= >= > > ;; complex
563 conjugate realpart imagpart phase
564 min max logand logior logxor lognot ffloor fceiling
565 ftruncate fround signum cis
569 (defpackage :lisp-stat-unittests
572 :lisp-stat
:lisp-stat-data-examples
)
573 (:shadowing-import-from
:lisp-stat
574 call-method call-next-method
;; objects
575 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
;; lsmath
576 asin acos atan sinh cosh tanh asinh acosh atanh float random
577 truncate floor ceiling round minusp zerop plusp evenp oddp
578 < <= = /= >= > ;; complex
579 conjugate realpart imagpart phase
580 min max logand logior logxor lognot ffloor fceiling
581 ftruncate fround signum cis
)
582 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard
; exec
583 almost
= almost
=lists numerical
=)) ; compare
585 (defpackage :cls-dataframe-example
587 :lift
:lisp-stat-unittests
588 :lisp-stat-data-examples
590 (:export absorbtion aluminum iron
))
593 (defpackage :lisp-stat-optimize
598 :lisp-stat-object-system
600 :lisp-stat-compound-data
606 :lisp-stat-linalg-data
610 (:shadowing-import-from
:lisp-stat-object-system
611 call-method call-next-method
)
612 (:shadowing-import-from
:lisp-stat-math
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 conjugate realpart imagpart phase
617 min max logand logior logxor lognot ffloor fceiling
618 ftruncate fround signum cis
)
624 newtonmax nelmeadmax
))