need to document package structure somewhere -- it's in Docs, but it might be better...
[CommonLispStat.git] / src / packages.lisp
blobf03b40e99954901c7147f266e6920dc245dc990f
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-09-24 11:41:52 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
8 ;;; on how it arrives.
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.
15 (in-package :cl-user)
17 ;;; Current structure, dependencies:
19 (progn
20 (ls-user :depends-on lisp-stat)
21 (lisp-stat :depends-on '(cls-dataframe
22 cls-data
23 lisp-matrix
25 (cls-dataframe :depends-on cls-data)
26 |#
30 ;;; Basics
33 (defpackage :lisp-stat-object-system
34 (:nicknames :ls-objects :lsos)
35 (:use :common-lisp)
36 (:shadow :call-method :call-next-method)
37 (:export ls-object objectp *object* kind-of-p make-object
38 *message-hook*
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
44 ;;; package.
46 (defpackage :lisp-stat-types
47 (:documentation "Provides some typeing for LispStat, but is clearly
48 a bit incomplete.")
49 (:use :common-lisp)
50 (:export fixnump
51 check-nonneg-fixnum check-one-nonneg-fixnum
52 check-one-fixnum check-one-real check-one-number))
54 (defpackage :lisp-stat-float
55 (:use :common-lisp)
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
70 (:use :common-lisp
71 :lisp-stat-object-system
72 :lisp-stat-types)
73 (:shadowing-import-from :lisp-stat-object-system
74 call-next-method call-method)
75 (:export compound-data-p *compound-data-proto*
76 compound-object-p
77 compound-data-seq compound-data-length
78 element-list element-seq
79 sort-data order rank
80 recursive-map-elements map-elements repeat
81 check-sequence
82 get-next-element make-next-element set-next-element
83 ;; sequencep
84 iseq ordered-nneg-seq
85 select split-list which
86 difference rseq
87 flatten-list))
89 (defpackage :lisp-stat-macros
90 (:use :common-lisp
91 :lisp-stat-compound-data)
92 (:export make-rv-function make-rv-function-1))
94 (defpackage :lisp-stat-basics
95 (:use :common-lisp
96 :lisp-stat-object-system
97 :lisp-stat-types
98 :lisp-stat-float
99 :lisp-stat-macros
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
104 if-else sample))
106 (defpackage :lisp-stat-float
107 (:use :common-lisp)
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
120 (:use :common-lisp
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
129 them later.")
130 (:use :common-lisp)
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
141 (:use :common-lisp
142 :xarray
143 :lisp-matrix)
144 (:shadowing-import-from :xarray slice)
145 (:export
146 ;; generic container class for data -- if small enough
147 ;; could be value, otherwise might be reference.
148 dataframe-like
149 dataframe-array
150 make-dataframe
152 ;; accessors
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
161 dataset
162 list-of-columns ;; list-of-variables
163 list-of-rows ;; list-of-observations
166 (defpackage :cls-data
167 (:use :common-lisp
168 :xarray
169 :lisp-matrix
170 :cls-dataframe) ; for dataframe
171 (:shadowing-import-from :xarray slice)
172 (:export listoflist->dataframe
173 listoflist->array
174 listoflist->matrix-like))
176 lists-of-same-size
177 equal-listoflist
178 transpose-listoflist
181 (defpackage :cls-dataimport
182 (:documentation "Data I/O and similar import technologies.")
183 (:use :common-lisp
184 :lisp-stat-object-system
185 :cls-dataframe
186 :cls-data
187 :rsm.string)
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.")
195 (:use :common-lisp
196 :lisp-matrix)
197 (:export
198 ;; data structures for model and model/data combination
199 model statistical-model analysis))
201 ;;; visualization
203 (defpackage :cls-visualize
204 (:use :common-lisp
205 :lisp-matrix
206 :cls-dataframe)
207 (:shadowing-import-from :xarray slice)
211 (defpackage :cls-visualize-plplot
212 (:use :common-lisp
213 :lisp-matrix
214 :cls-dataframe
215 :cl-plplot-system)
216 (:export
217 ;; examples
218 plot-ex contour-plot-ex fn-contour-plot-ex shade-plot-ex 3D-plot-ex))
221 ;;; USER PACKAGES
223 (defpackage :lisp-stat-ffi-int
224 (:use :common-lisp
225 :cffi)
226 (:export ccl-store-integer ccl-store-double ccl-store-ptr
227 get-buf ))
229 (defpackage :lisp-stat-probability
230 (:use :common-lisp
231 :cffi
232 :lisp-stat-ffi-int
233 :lisp-stat-macros)
234 (:export log-gamma set-seed
235 uniform-rand
236 normal-cdf normal-quant normal-dens normal-rand
237 bivnorm-cdf
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
250 (:use :common-lisp
251 :lisp-stat-object-system
252 :lisp-stat-macros
253 :lisp-stat-compound-data
254 :lisp-stat-float)
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 < <= =
267 /= >= > ;; complex
268 conjugate realpart imagpart phase min max
269 logand logior logxor lognot ffloor fceiling ftruncate fround
270 signum cis)
271 (:documentation "Vectorization of numerical functions"))
274 #| ;; some of this goes back in, but not all of it?
275 (defpackage :lisp-stat-linalg
276 (:use :common-lisp
277 :cffi
278 :lisp-matrix
279 :lisp-stat-math
280 :lisp-stat-types
281 :lisp-stat-float
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
299 lowess))
306 (defpackage :lisp-stat-data
307 (:documentation "Data management, integration, I/O, and other data technologies.")
308 (:nicknames :ls-data)
309 (:use :common-lisp
310 :lisp-stat-object-system
311 :lisp-stat-config
312 :lisp-stat-types
313 :lisp-stat-compound-data)
314 (:shadowing-import-from :lisp-stat-object-system
315 call-method call-next-method)
316 (:export open-file-dialog read-data-file read-data-columns load-data
317 load-example *variables* *ask-on-redefine*
318 def variables savevar undef))
320 (defpackage :lisp-stat-descriptive-statistics
321 (:use :common-lisp
322 :lisp-matrix
323 :lisp-stat-data
324 :lisp-stat-math
325 :lisp-stat-compound-data
326 :lisp-stat-basics)
327 (:shadowing-import-from :lisp-stat-math ;; life is a vector!
328 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
329 asin acos atan sinh cosh tanh asinh acosh atanh float random
330 truncate floor ceiling round minusp zerop plusp evenp oddp
331 < <= = /= >= > ;; complex
332 conjugate realpart imagpart phase
333 min max logand logior logxor lognot ffloor fceiling
334 ftruncate fround signum cis)
335 (:export mean standard-deviation variance
336 quantile median interquartile-range
337 fivnum sample))
339 (defpackage :lisp-stat-regression-linear
340 (:use :common-lisp
341 :lisp-matrix
342 :lisp-stat-basics
343 :lisp-stat-compound-data
344 :lisp-stat-descriptive-statistics )
345 (:shadowing-import-from :lisp-stat-object-system
346 call-method call-next-method)
347 (:export regression-model fit-model
349 estimates covariance-matrix
350 ;; functions for helpers
351 lm xtxinv
352 print-object ;; for method dispatch
355 (defpackage :common-lisp-statistics
356 (:documentation "Experimentation package for LispStat. Serious work
357 should be packaged up as a separate but similar package to help
358 drive reproducibility. By this I mean, creating a
359 data/analytics/analysis package with the minimal set of
360 objects/packages required.")
361 (:nicknames :cls :common-lisp-statistics :lisp-stat)
362 (:use :common-lisp
363 :xarray ;; generic reference -- internally supporting array, lol structs
364 :lisp-matrix ;; conversion to a more robust linalg approach
365 :lisp-stat-config
366 :lisp-stat-object-system
367 :lisp-stat-compound-data
368 :lisp-stat-probability
369 :lisp-stat-types
370 :lisp-stat-float
371 :lisp-stat-basics
372 :lisp-stat-data
373 :cls-dataframe
374 :cls-data
375 :lisp-stat-math
376 :lisp-stat-descriptive-statistics
377 :lisp-stat-regression-linear
378 :cls-visualize
379 ;; :cybertiggyr-dsv
380 ;; :cls-visualize-plplot
382 (:shadowing-import-from :xarray slice)
383 (:shadowing-import-from :lisp-stat-object-system
384 call-method call-next-method)
385 (:shadowing-import-from :lisp-stat-math
386 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
387 asin acos atan sinh cosh tanh asinh acosh atanh float random
388 truncate floor ceiling round minusp zerop plusp evenp oddp
389 < <= = /= >= >
390 ;;complex
391 conjugate realpart imagpart phase
393 min max
394 logand logior logxor lognot
395 ffloor fceiling ftruncate fround
396 signum cis)
397 (:export
398 ;; lisp-stat-config:
399 *default-path* *lsos-files* *basic-files* *ls-files*
400 *lispstat-home-dir* *lispstat-data-dir* *lispstat-examples-dir*
402 ;; lsobjects :
403 defproto defproto2
404 defmeth send proto-slot-value
406 ;; lstypes :
407 fixnump check-nonneg-fixnum check-one-fixnum
408 check-one-nonneg-fixnum
409 check-one-real check-one-number
411 ;; lsmacros:
413 ;; lsfloat :
414 machine-epsilon
416 ;; compound :
417 compound-data-p *compound-data-proto* compound-object-p
418 compound-data-seq compound-data-length
419 element-list element-seq
420 sort-data order rank
421 recursive-map-elements map-elements
422 repeat
423 check-sequence
424 get-next-element make-next-element set-next-element
425 ;; sequencep
426 iseq
427 ordered-nneg-seq
428 select which
429 difference rseq
431 ;; lsmath.lsp
432 ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
433 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
434 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
435 /= >= > ;; complex
436 conjugate realpart imagpart phase min max
437 logand logior logxor lognot ffloor fceiling ftruncate fround
438 signum cis
440 #| ;; The following need to be re-found in lisp-matrix...
442 ;; matrices.lisp
443 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
444 column-list inner-product outer-product cross-product transpose
445 bind-columns bind-rows
447 ;; linalg.lisp
448 chol-decomp lu-decomp lu-solve determinant inverse
449 sv-decomp qr-decomp rcondest make-rotation spline
450 kernel-dens kernel-smooth
451 fft make-sweep-matrix sweep-operator ax+y eigen
452 check-real
453 covariance-matrix matrix print-matrix solve
454 backsolve eigenvalues eigenvectors accumulate cumsum combine
455 lowess
457 ;; in linalg.lisp, possibly not supported by matlisp
458 spline kernel-dens kernel-smooth
462 ;; optimize.lsp
463 newtonmax nelmeadmax
465 ;; lispstat-macros
466 make-rv-function make-rv-function-1
468 ;; xarray
469 xref xtype xdims xdim xdims*
470 lists-of-same-size equal-listoflist transpose-listoflist
472 ;; data
473 open-file-dialog read-data-file read-data-columns load-data
474 load-example *variables* *ask-on-redefine*
475 def variables savevar undef
477 ;; dataframe
478 dataframe-like dataframe-array make-dataframe
479 varlabels caselabels nrows ncols
480 dataframe-dimension dataframe-dimensons
481 dfref dfref-case dfref-var
482 consistent-dataframe-p
483 dataset list-of-columns list-of-rows
485 ;; listoflist
486 listoflist->dataframe listoflist->array listoflist->matrix-like
488 ;; statistics.lsp (descriptions, should probably be moved
489 ;; later...?
490 standard-deviation quantile median interquartile-range
491 fivnum sample
493 ;; probability (dists.lisp)
494 log-gamma set-seed
495 uniform-rand normal-cdf normal-quant normal-dens
496 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
497 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
498 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
499 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
500 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
501 binomial-cdf binomial-quant binomial-pmf binomial-rand
503 ;; Here is where we have a problem -- lispstat core should be core
504 ;; data management and config problems, with packages providing
505 ;; specialized extensions to LispStat, i.e. regression, nonlin
506 ;; regression, bayesian regression via laplace approximation, etc.
508 ;; The following could be considered "recommended packages",
509 ;; similar to the idea of the recommended packages in R. Probably
510 ;; we want them to do the exporting within that package, therefore
511 ;; NOT being able to lock the "data-ish" package, but only the
512 ;; subpackages prior to export.
514 ;; regression.lsp
515 ;; -- linear regressin models.
516 regression-model fit-model
517 estimates covariance-matrix
519 regression-model-proto x y intercept sweep-matrix
520 basis weights included total-sum-of-squares residual-sum-of-squares
521 predictor-names response-name case-labels
522 lm xtxinv
524 ;; nonlin.lsp
525 ;; -- nonlinear regression models
526 nreg-model nreg-model-proto mean-function theta-hat epsilon
527 count-limit verbose
528 ;; we might need something like xtxinv here? But should be
529 ;; encapsulated, so we use the one in regression.lisp
531 ;; bayes.lsp
532 bayes-model bayes-model-proto bayes-internals
534 ;; plots.lisp
535 plot-ex
536 contour-plot-ex
537 fn-contour-plot-ex
538 shade-plot-ex
539 3D-plot-ex
544 ;;;; PACKAGES FOR USEABILITY
546 (defpackage :lisp-stat-data-examples
547 (:documentation "Example data for unittests, examples, illustrations,")
548 (:use :common-lisp
549 :common-lisp-statistics)
550 (:shadowing-import-from :lisp-stat
551 call-method call-next-method
553 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
554 asin acos atan sinh cosh tanh asinh acosh atanh float random
555 truncate floor ceiling round minusp zerop plusp evenp oddp
556 < <= = /= >= > > ;; complex
557 conjugate realpart imagpart phase
558 min max logand logior logxor lognot ffloor fceiling
559 ftruncate fround signum cis
561 <= float imagpart)
562 (:export iron aluminum absorbtion
563 diabetes dlabs))
566 (defpackage :lisp-stat-user
567 (:documentation "Experimentation package for LispStat. Serious work
568 should be placed in a similar package elsewhere for
569 reproducibility. But this should hint as to what needs to be done
570 for a user- or analysis-package.")
571 (:nicknames :ls-user)
572 (:use :common-lisp ; always needed for user playgrounds!
573 :lisp-matrix
574 :common-lisp-statistics
575 :lisp-stat-data-examples) ;; this last is to have 'things to play with'
576 (:shadowing-import-from :lisp-stat
577 call-method call-next-method
579 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
580 asin acos atan sinh cosh tanh asinh acosh atanh float random
581 truncate floor ceiling round minusp zerop plusp evenp oddp
582 < <= = /= >= > > ;; complex
583 conjugate realpart imagpart phase
584 min max logand logior logxor lognot ffloor fceiling
585 ftruncate fround signum cis
587 <= float imagpart))
589 (defpackage :lisp-stat-unittests
590 (:use :common-lisp
591 :lift :lisp-matrix
592 :lisp-stat :lisp-stat-data-examples)
593 (:shadowing-import-from :lisp-stat
594 call-method call-next-method ;; objects
595 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath
596 asin acos atan sinh cosh tanh asinh acosh atanh float random
597 truncate floor ceiling round minusp zerop plusp evenp oddp
598 < <= = /= >= > ;; complex
599 conjugate realpart imagpart phase
600 min max logand logior logxor lognot ffloor fceiling
601 ftruncate fround signum cis)
602 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard ; exec
603 almost= almost=lists numerical=)) ; compare
605 (defpackage :cls-dataframe-example
606 (:use :common-lisp
607 :lift :lisp-stat-unittests
608 :lisp-stat-data-examples
609 :cls-dataframe)
610 (:export absorbtion aluminum iron))
613 (defpackage :lisp-stat-optimize
614 (:use :common-lisp
615 :cffi
616 :lisp-matrix
617 :lisp-stat-ffi-int
618 :lisp-stat-object-system
619 :lisp-stat-types
620 :lisp-stat-compound-data
621 :lisp-stat-math
622 :lisp-stat-float
623 :lisp-stat-basics
625 :lisp-stat-matrix
626 :lisp-stat-linalg-data
627 :lisp-stat-linalg
630 (:shadowing-import-from :lisp-stat-object-system
631 call-method call-next-method)
632 (:shadowing-import-from :lisp-stat-math
633 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
634 asin acos atan sinh cosh tanh asinh acosh atanh float random
635 truncate floor ceiling round minusp zerop plusp evenp oddp
636 < <= = /= >= > complex conjugate realpart imagpart phase
637 min max logand logior logxor lognot ffloor fceiling
638 ftruncate fround signum cis)
639 (:export
640 ;; derivatives
641 numgrad numhess
643 ;; optimization
644 newtonmax nelmeadmax))