restructured talk, show what we have then what we plan.
[CommonLispStat.git] / src / packages.lisp
blob7108d24f38721e55c7522df1b5d192866005166b
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-07-11 14: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
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 ;;; Basics
20 (defpackage :lisp-stat-object-system
21 (:nicknames :ls-objects :lsos)
22 (:use :common-lisp)
23 (:shadow :call-method :call-next-method)
24 (:export ls-object objectp *object* kind-of-p make-object
25 *message-hook*
26 *set-slot-hook* proto-slot-value self
27 send call-next-method call-method
28 defmeth defproto instance-slots proto-name))
30 (defpackage :lisp-stat-types
31 (:documentation "Provides some typeing for LispStat, but is clearly
32 a bit incomplete.")
33 (:use :common-lisp)
34 (:export fixnump
35 check-nonneg-fixnum check-one-nonneg-fixnum
36 check-one-fixnum check-one-real check-one-number))
38 (defpackage :lisp-stat-float
39 (:use :common-lisp)
40 (:export +stat-float-typing+ +stat-cfloat-typing+ +stat-float-template+
41 machine-epsilon base-float makedouble
43 make-base-trans-fun-2 make-base-trans-fun
45 base-log base-exp base-expt base-sqrt base-sin base-cos
46 base-tan base-asin base-acos base-atan base-sinh
47 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
48 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
49 BASE-FROUND BASE-SIGNUM BASE-CIS))
51 (defpackage :lisp-stat-compound-data
52 (:use :common-lisp
53 :lisp-stat-object-system
54 :lisp-stat-types)
55 (:shadowing-import-from :lisp-stat-object-system
56 call-next-method call-method)
57 (:export compound-data-p *compound-data-proto*
58 compound-object-p
59 compound-data-seq compound-data-length
60 element-list element-seq
61 sort-data order rank
62 recursive-map-elements map-elements repeat
63 check-sequence
64 get-next-element make-next-element set-next-element
65 ;; sequencep
66 iseq ordered-nneg-seq
67 select split-list which
68 difference rseq
69 flatten-list))
71 (defpackage :lisp-stat-macros
72 (:use :common-lisp
73 :lisp-stat-compound-data)
74 (:export make-rv-function make-rv-function-1))
76 (defpackage :lisp-stat-basics
77 (:use :common-lisp
78 :lisp-stat-object-system
79 :lisp-stat-types
80 :lisp-stat-float
81 :lisp-stat-macros
82 :lisp-stat-compound-data)
83 (:shadowing-import-from :lisp-stat-object-system
84 call-method call-next-method)
85 (:export permute-array sum prod count-elements mean
86 if-else sample))
88 (defpackage :lisp-stat-float
89 (:use :common-lisp)
90 (:export +stat-float-typing+ +stat-cfloat-typing+ +stat-float-template+
91 machine-epsilon base-float makedouble
93 make-base-trans-fun-2 make-base-trans-fun
95 BASE-LOG BASE-EXP BASE-EXPT BASE-SQRT BASE-SIN BASE-COS
96 BASE-TAN BASE-ASIN BASE-ACOS BASE-ATAN BASE-SINH
97 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
98 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
99 BASE-FROUND BASE-SIGNUM BASE-CIS))
101 (defpackage :lisp-stat-macros
102 (:use :common-lisp
103 :lisp-stat-compound-data)
104 (:export make-rv-function make-rv-function-1))
106 ;;; NEW CLOS STRUCTURE
110 (defpackage :cls-dataframe
111 (:use :common-lisp
112 :lisp-matrix)
113 (:export
114 ;; generic container class for data -- if small enough
115 ;; could be value, otherwise might be reference.
116 dataframe-like
117 dataframe-array
118 make-dataframe
120 ;; accessors
121 varlabels caselabels nrows ncols
122 dataframe-dimension dataframe-dimensons
123 dfref dfref-case dfref-var
124 consistent-dataframe-p
126 dataset
127 list-of-columns ;; list-of-variables
128 list-of-rows ;; list-of-observations
132 (defpackage :cls-data-listoflist
133 (:use :common-lisp
134 :lisp-matrix
135 :cls-dataframe) ; for dataframe
136 (:export lists-of-same-size
137 equal-listoflist
138 transpose-listoflist
139 listoflist->dataframe
140 listoflist->array
141 listoflist->matrix-like))
144 (defpackage :cls-dataimport
145 (:documentation "Data I/O and similar import technologies.")
146 (:use :common-lisp
147 :lisp-stat-object-system
148 :cls-dataframe
149 :cls-data-listoflist
150 :rsm.string)
151 (:shadowing-import-from :lisp-stat-object-system
152 call-method call-next-method)
153 (:export dsvstream->dataframe dsvstream->matrix dsvstream->listoflist))
156 (defpackage :lisp-stat-model
157 (:documentation "Model management for data analysis.")
158 (:use :common-lisp
159 :lisp-matrix)
160 (:export
161 ;; data structures for model and model/data combination
162 model statistical-model analysis))
164 ;;; visualization
166 (defpackage :cls-visualize
167 (:use :common-lisp
168 :lisp-matrix
169 :cls-dataframe))
172 (defpackage :cls-visualize-plplot
173 (:use :common-lisp
174 :lisp-matrix
175 :cls-dataframe
176 :cl-plplot-system)
177 (:export
178 ;; examples
179 plot-ex contour-plot-ex fn-contour-plot-ex shade-plot-ex 3D-plot-ex))
182 ;;; USER PACKAGES
184 (defpackage :lisp-stat-ffi-int
185 (:use :common-lisp
186 :cffi)
187 (:export ccl-store-integer ccl-store-double ccl-store-ptr
188 get-buf ))
190 (defpackage :lisp-stat-probability
191 (:use :common-lisp
192 :cffi
193 :lisp-stat-ffi-int
194 :lisp-stat-macros)
195 (:export log-gamma set-seed
196 uniform-rand
197 normal-cdf normal-quant normal-dens normal-rand
198 bivnorm-cdf
199 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
200 gamma-cdf gamma-quant gamma-dens gamma-rand
201 chisq-cdf chisq-quant chisq-dens chisq-rand
202 beta-cdf beta-quant beta-dens beta-rand
203 t-cdf t-quant t-dens t-rand
204 f-cdf f-quant f-dens f-rand
205 poisson-cdf poisson-quant poisson-pmf poisson-rand
206 binomial-cdf binomial-quant binomial-pmf binomial-rand))
210 (defpackage :lisp-stat-math
211 (:use :common-lisp
212 :lisp-stat-object-system
213 :lisp-stat-macros
214 :lisp-stat-compound-data
215 :lisp-stat-float)
216 (:shadowing-import-from :lisp-stat-object-system
217 call-method call-next-method)
218 (:shadow expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
219 asin acos atan sinh cosh tanh asinh acosh atanh float random
220 truncate floor ceiling round minusp zerop plusp evenp oddp
221 < <= = /= >= > ;; complex
222 conjugate realpart imagpart phase
223 min max logand logior logxor lognot ffloor fceiling
224 ftruncate fround signum cis)
225 (:export ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
226 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
227 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
228 /= >= > ;; complex
229 conjugate realpart imagpart phase min max
230 logand logior logxor lognot ffloor fceiling ftruncate fround
231 signum cis)
232 (:documentation "Vectorization of numerical functions"))
235 #| ;; some of this goes back in, but not all of it?
236 (defpackage :lisp-stat-linalg
237 (:use :common-lisp
238 :cffi
239 :lisp-matrix
240 :lisp-stat-math
241 :lisp-stat-types
242 :lisp-stat-float
243 :lisp-stat-compound-data)
244 (:shadowing-import-from :lisp-stat-math
245 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
246 asin acos atan sinh cosh tanh asinh acosh atanh float random
247 truncate floor ceiling round minusp zerop plusp evenp oddp
248 < <= = /= >= > complex conjugate realpart imagpart phase
249 min max logand logior logxor lognot ffloor fceiling
250 ftruncate fround signum cis)
251 (:export chol-decomp lu-decomp lu-solve determinant inverse
252 sv-decomp qr-decomp rcondest make-rotation spline
253 kernel-dens kernel-smooth
254 fft make-sweep-matrix sweep-operator ax+y eigen
256 check-real ;; for optimize
258 covariance-matrix matrix print-matrix solve
259 backsolve eigenvalues eigenvectors accumulate cumsum combine
260 lowess))
267 (defpackage :lisp-stat-data
268 (:documentation "Data management, integration, I/O, and other data technologies.")
269 (:nicknames :ls-data)
270 (:use :common-lisp
271 :lisp-stat-object-system
272 :lisp-stat-config
273 :lisp-stat-types
274 :lisp-stat-compound-data)
275 (:shadowing-import-from :lisp-stat-object-system
276 call-method call-next-method)
277 (:export open-file-dialog read-data-file read-data-columns load-data
278 load-example *variables* *ask-on-redefine*
279 def variables savevar undef))
281 (defpackage :lisp-stat-descriptive-statistics
282 (:use :common-lisp
283 :lisp-stat-data
284 :lisp-stat-math
285 :lisp-stat-compound-data
286 :lisp-matrix
287 :lisp-stat-basics)
288 (:shadowing-import-from :lisp-stat-math ;; life is a vector!
289 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
290 asin acos atan sinh cosh tanh asinh acosh atanh float random
291 truncate floor ceiling round minusp zerop plusp evenp oddp
292 < <= = /= >= > ;; complex
293 conjugate realpart imagpart phase
294 min max logand logior logxor lognot ffloor fceiling
295 ftruncate fround signum cis)
296 (:export standard-deviation
297 quantile median interquartile-range
298 fivnum sample))
301 (defpackage :lisp-stat-regression-linear
302 (:use :common-lisp
303 :lisp-matrix
304 :lisp-stat-basics
305 :lisp-stat-compound-data
306 :lisp-stat-descriptive-statistics )
307 (:shadowing-import-from :lisp-stat-object-system
308 call-method call-next-method)
309 (:export regression-model fit-model
311 estimates covariance-matrix
312 ;; functions for helpers
313 lm xtxinv
314 print-object ;; for method dispatch
317 (defpackage :common-lisp-statistics
318 (:documentation "Experimentation package for LispStat. Serious work
319 should be packaged up elsewhere for reproducibility. By this I
320 mean, creating a data/analytics/analysis package with the minimal
321 set of objects required.")
322 (:nicknames :cls :common-lisp-statistics :lisp-stat)
323 (:use :common-lisp
324 :lisp-stat-object-system
325 :lisp-stat-compound-data
326 :lisp-stat-probability
327 :lisp-stat-types
328 :lisp-stat-float
329 :lisp-stat-basics
330 :lisp-stat-data
331 :cls-dataframe
332 :cls-data-listoflist
333 :lisp-stat-math
334 :lisp-matrix ;; conversion to a more robust linalg approach
335 :lisp-stat-descriptive-statistics
336 :lisp-stat-regression-linear
337 :cybertiggyr-dsv
338 :cls-visualize
339 ;; :cls-visualize-plplot
341 (:shadowing-import-from :lisp-stat-object-system
342 call-method call-next-method)
343 (:shadowing-import-from :lisp-stat-math
344 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
345 asin acos atan sinh cosh tanh asinh acosh atanh float random
346 truncate floor ceiling round minusp zerop plusp evenp oddp
347 < <= = /= >= >
348 ;;complex
349 conjugate realpart imagpart phase
351 min max
352 logand logior logxor lognot
353 ffloor fceiling ftruncate fround
354 signum cis)
355 (:export
356 ;; lsobjects :
357 defproto defproto2
358 defmeth send
359 proto-slot-value
361 ;; lstypes :
362 fixnump check-nonneg-fixnum check-one-fixnum
363 check-one-nonneg-fixnum
364 check-one-real check-one-number
366 ;; lsmacros:
368 ;; lsfloat :
369 machine-epsilon
371 ;; compound :
372 compound-data-p *compound-data-proto* compound-object-p
373 compound-data-seq compound-data-length
374 element-list element-seq
375 sort-data order rank
376 recursive-map-elements map-elements
377 repeat
378 check-sequence
379 get-next-element make-next-element set-next-element
380 ;; sequencep
381 iseq
382 ordered-nneg-seq
383 select which
384 difference rseq
386 ;; lsmath.lsp
387 ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
388 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
389 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
390 /= >= > ;; complex
391 conjugate realpart imagpart phase min max
392 logand logior logxor lognot ffloor fceiling ftruncate fround
393 signum cis
395 #| ;; The following need to be re-found in lisp-matrix...
397 ;; matrices.lisp
398 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
399 column-list inner-product outer-product cross-product transpose
400 bind-columns bind-rows
402 ;; linalg.lisp
403 chol-decomp lu-decomp lu-solve determinant inverse
404 sv-decomp qr-decomp rcondest make-rotation spline
405 kernel-dens kernel-smooth
406 fft make-sweep-matrix sweep-operator ax+y eigen
407 check-real
408 covariance-matrix matrix print-matrix solve
409 backsolve eigenvalues eigenvectors accumulate cumsum combine
410 lowess
412 ;; in linalg.lisp, possibly not supported by matlisp
413 spline kernel-dens kernel-smooth
417 ;; optimize.lsp
418 newtonmax nelmeadmax
420 ;; lispstat-macros
421 make-rv-function make-rv-function-1
423 ;; xarray
424 xref xtype xdims xdim xdims*
426 ;; data
427 open-file-dialog read-data-file read-data-columns load-data
428 load-example *variables* *ask-on-redefine*
429 def variables savevar undef
431 ;; dataframe
432 dataframe-like dataframe-array make-dataframe
433 varlabels caselabels nrows ncols
434 dataframe-dimension dataframe-dimensons
435 dfref dfref-case dfref-var
436 consistent-dataframe-p
437 dataset
438 list-of-columns list-of-rows
442 ;; listoflist
443 lists-of-same-size equal-listoflist
444 transpose-listoflist
445 listoflist->dataframe listoflist->array listoflist->matrix-like
447 ;; statistics.lsp (descriptions, should probably be moved
448 ;; later...?
449 standard-deviation quantile median interquartile-range
450 fivnum sample
452 ;; probability (dists.lisp)
453 log-gamma set-seed
454 uniform-rand normal-cdf normal-quant normal-dens
455 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
456 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
457 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
458 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
459 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
460 binomial-cdf binomial-quant binomial-pmf binomial-rand
462 ;; Here is where we have a problem -- lispstat core should be core
463 ;; data management and config problems, with packages providing
464 ;; specialized extensions to LispStat, i.e. regression, nonlin
465 ;; regression, bayesian regression via laplace approximation, etc.
467 ;; The following could be considered "recommended packages",
468 ;; similar to the idea of the recommended packages in R. Probably
469 ;; we want them to do the exporting within that package, therefore
470 ;; NOT being able to lock the "data-ish" package, but only the
471 ;; subpackages prior to export.
473 ;; regression.lsp
474 ;; -- linear regressin models.
475 regression-model fit-model
476 estimates covariance-matrix
478 regression-model-proto x y intercept sweep-matrix
479 basis weights included total-sum-of-squares residual-sum-of-squares
480 predictor-names response-name case-labels
481 lm xtxinv
483 ;; nonlin.lsp
484 ;; -- nonlinear regression models
485 nreg-model nreg-model-proto mean-function theta-hat epsilon
486 count-limit verbose
487 ;; we might need something like xtxinv here? But should be
488 ;; encapsulated, so we use the one in regression.lisp
490 ;; bayes.lsp
491 bayes-model bayes-model-proto bayes-internals
493 ;; plots.lisp
494 plot-ex
495 contour-plot-ex
496 fn-contour-plot-ex
497 shade-plot-ex
498 3D-plot-ex
503 ;;;; PACKAGES FOR USEABILITY
505 (defpackage :lisp-stat-data-examples
506 (:documentation "Example data for unittests, examples, illustrations,")
507 (:use :common-lisp
508 :common-lisp-statistics)
509 (:shadowing-import-from :lisp-stat
510 call-method call-next-method
512 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
513 asin acos atan sinh cosh tanh asinh acosh atanh float random
514 truncate floor ceiling round minusp zerop plusp evenp oddp
515 < <= = /= >= > > ;; complex
516 conjugate realpart imagpart phase
517 min max logand logior logxor lognot ffloor fceiling
518 ftruncate fround signum cis
520 <= float imagpart)
521 (:export iron aluminum absorbtion
522 diabetes dlabs))
525 (defpackage :lisp-stat-user
526 (:documentation "Experimentation package for LispStat. Serious work
527 should be placed in a similar package elsewhere for
528 reproducibility. But this should hint as to what needs to be done
529 for a user- or analysis-package.")
530 (:nicknames :ls-user)
531 (:use :common-lisp ; always needed for user playgrounds!
532 :lisp-matrix
533 :common-lisp-statistics
534 :lisp-stat-data-examples) ;; this last is to have 'things to play with'
535 (:shadowing-import-from :lisp-stat
536 call-method call-next-method
538 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
539 asin acos atan sinh cosh tanh asinh acosh atanh float random
540 truncate floor ceiling round minusp zerop plusp evenp oddp
541 < <= = /= >= > > ;; complex
542 conjugate realpart imagpart phase
543 min max logand logior logxor lognot ffloor fceiling
544 ftruncate fround signum cis
546 <= float imagpart))
548 (defpackage :lisp-stat-unittests
549 (:use :common-lisp
550 :lift :lisp-matrix
551 :lisp-stat :lisp-stat-data-examples)
552 (:shadowing-import-from :lisp-stat
553 call-method call-next-method ;; objects
554 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath
555 asin acos atan sinh cosh tanh asinh acosh atanh float random
556 truncate floor ceiling round minusp zerop plusp evenp oddp
557 < <= = /= >= > ;; complex
558 conjugate realpart imagpart phase
559 min max logand logior logxor lognot ffloor fceiling
560 ftruncate fround signum cis)
561 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard ; exec
562 almost= almost=lists numerical=)) ; compare
564 (defpackage :cls-dataframe-example
565 (:use :common-lisp
566 :lift :lisp-stat-unittests
567 :lisp-stat-data-examples
568 :cls-dataframe)
569 (:export absorbtion aluminum iron))
572 (defpackage :lisp-stat-optimize
573 (:use :common-lisp
574 :cffi
575 :lisp-matrix
576 :lisp-stat-ffi-int
577 :lisp-stat-object-system
578 :lisp-stat-types
579 :lisp-stat-compound-data
580 :lisp-stat-math
581 :lisp-stat-float
582 :lisp-stat-basics
584 :lisp-stat-matrix
585 :lisp-stat-linalg-data
586 :lisp-stat-linalg
589 (:shadowing-import-from :lisp-stat-object-system
590 call-method call-next-method)
591 (:shadowing-import-from :lisp-stat-math
592 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
593 asin acos atan sinh cosh tanh asinh acosh atanh float random
594 truncate floor ceiling round minusp zerop plusp evenp oddp
595 < <= = /= >= > complex conjugate realpart imagpart phase
596 min max logand logior logxor lognot ffloor fceiling
597 ftruncate fround signum cis)
598 (:export
599 ;; derivatives
600 numgrad numhess
602 ;; optimization
603 newtonmax nelmeadmax))