clean up packaging for lsbasics package.
[CommonLispStat.git] / src / packages.lisp
blob9834662d50d43be2c405e5496b8ed0af6a4b7f5c
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-02-13 17:18:50 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 ;;; This organization and structure is new to the 21st Century
16 ;;; version.
18 (in-package :cl-user)
20 ;;; LispStat Basics
22 (defpackage :lisp-stat-object-system
23 (:nicknames :ls-objects :lsos)
24 (:use :common-lisp)
25 (:shadow :call-method :call-next-method :slot-value)
26 (:export ls-object objectp *object* kind-of-p make-object
27 *message-hook*
28 *set-slot-hook* slot-value self
29 send call-next-method call-method
30 defmeth defproto instance-slots proto-name))
32 (defpackage :lisp-stat-types
33 (:documentation "Provides some typeing for LispStat, but is clearly
34 a bit incomplete.")
35 (:use :common-lisp)
36 (:export fixnump
37 check-nonneg-fixnum check-one-nonneg-fixnum
38 check-one-fixnum check-one-real check-one-number))
40 (defpackage :lisp-stat-float
41 (:use :common-lisp)
42 (:export +stat-float-typing+ +stat-cfloat-typing+ +stat-float-template+
43 machine-epsilon base-float makedouble
45 make-base-trans-fun-2 make-base-trans-fun
47 base-log base-exp base-expt base-sqrt base-sin base-cos
48 base-tan base-asin base-acos base-atan base-sinh
49 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
50 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
51 BASE-FROUND BASE-SIGNUM BASE-CIS))
53 (defpackage :lisp-stat-compound-data
54 (:use :common-lisp
55 :lisp-stat-object-system
56 :lisp-stat-types)
57 (:shadowing-import-from :lisp-stat-object-system
58 slot-value
59 call-next-method call-method)
60 (:export compound-data-p *compound-data-proto*
61 compound-object-p
62 compound-data-seq compound-data-length
63 element-list element-seq
64 sort-data order rank
65 recursive-map-elements map-elements repeat
66 check-sequence
67 get-next-element make-next-element set-next-element
68 ;; sequencep
69 iseq ordered-nneg-seq
70 select split-list which
71 difference rseq
72 flatten-list))
74 (defpackage :lisp-stat-macros
75 (:use :common-lisp
76 :lisp-stat-compound-data)
77 (:export make-rv-function make-rv-function-1))
79 (defpackage :lisp-stat-basics
80 (:use :common-lisp
81 :lisp-stat-object-system
82 :lisp-stat-types
83 :lisp-stat-float
84 :lisp-stat-macros
85 :lisp-stat-compound-data)
86 (:shadowing-import-from :lisp-stat-object-system
87 slot-value call-method call-next-method)
88 (:export permute-array sum prod count-elements mean
89 if-else sample))
91 (defpackage :lisp-stat-float
92 (:use :common-lisp)
93 (:export +stat-float-typing+ +stat-cfloat-typing+ +stat-float-template+
94 machine-epsilon base-float makedouble
96 make-base-trans-fun-2 make-base-trans-fun
98 BASE-LOG BASE-EXP BASE-EXPT BASE-SQRT BASE-SIN BASE-COS
99 BASE-TAN BASE-ASIN BASE-ACOS BASE-ATAN BASE-SINH
100 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
101 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
102 BASE-FROUND BASE-SIGNUM BASE-CIS))
104 (defpackage :lisp-stat-macros
105 (:use :common-lisp
106 :lisp-stat-compound-data)
107 (:export make-rv-function make-rv-function-1))
109 ;;; NEW CLOS STRUCTURE
111 (defpackage :lisp-stat-data-clos
112 (:use :common-lisp
113 :lisp-matrix)
114 (:export get-variable-matrix get-variable-vector
115 ;; generic container class for data -- if small enough
116 ;; could be value, otherwise might be reference.
117 data-pointer))
120 (defpackage :lisp-stat-regression-linear-clos
121 (:use :common-lisp
122 :lisp-matrix
123 :lisp-stat-data-clos)
124 (:export regression-model))
128 ;;; USER PACKAGES
130 (defpackage :lisp-stat-ffi-int
131 (:use :common-lisp
132 :cffi)
133 (:export ccl-store-integer ccl-store-double ccl-store-ptr
134 get-buf ))
136 (defpackage :lisp-stat-probability
137 (:use :common-lisp
138 :cffi
139 :lisp-stat-ffi-int
140 :lisp-stat-macros)
141 (:export log-gamma set-seed
142 uniform-rand
143 normal-cdf normal-quant normal-dens normal-rand
144 bivnorm-cdf
145 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
146 gamma-cdf gamma-quant gamma-dens gamma-rand
147 chisq-cdf chisq-quant chisq-dens chisq-rand
148 beta-cdf beta-quant beta-dens beta-rand
149 t-cdf t-quant t-dens t-rand
150 f-cdf f-quant f-dens f-rand
151 poisson-cdf poisson-quant poisson-pmf poisson-rand
152 binomial-cdf binomial-quant binomial-pmf binomial-rand))
155 #| removed, replace by lisp-matrix
156 (defpackage :lisp-stat-matrix
157 (:use :common-lisp
158 :cffi
159 :lisp-stat-compound-data)
160 (:export matrixp ;; matrix -- conflicts!
161 num-rows num-cols matmult identity-matrix diagonal
162 row-list column-list inner-product outer-product
163 cross-product
164 ;; transpose bind-columns bind-rows
165 array-data-vector vector-to-array
167 check-matrix check-square-matrix
169 copy-array copy-vector
173 #| replaced by lisp-matrix
174 (defpackage :lisp-stat-linalg-data
175 (:use :common-lisp
176 :cffi
177 :lisp-stat-ffi-int
178 :lisp-stat-types
179 :lisp-stat-compound-data
180 :lisp-stat-matrix)
181 (:export ;; more to add
182 +mode-in+ +mode-re+ +mode-cx+ mode-of
184 la-data-mode la-allocate la-free
186 la-get-double la-put-double
187 la-put-integer
189 la-matrix la-free-matrix la-matrix-to-data la-data-to-matrix
190 la-vector la-free-vector la-vector-to-data la-data-to-vector ))
193 (defpackage :lisp-stat-math
194 (:use :common-lisp
195 :lisp-stat-object-system
196 :lisp-stat-macros
197 :lisp-stat-compound-data
198 :lisp-stat-float)
199 (:shadowing-import-from :lisp-stat-object-system
200 slot-value call-method call-next-method)
201 (:shadow expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
202 asin acos atan sinh cosh tanh asinh acosh atanh float random
203 truncate floor ceiling round minusp zerop plusp evenp oddp
204 < <= = /= >= > ;; complex
205 conjugate realpart imagpart phase
206 min max logand logior logxor lognot ffloor fceiling
207 ftruncate fround signum cis)
208 (:export ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
209 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
210 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
211 /= >= > ;; complex
212 conjugate realpart imagpart phase min max
213 logand logior logxor lognot ffloor fceiling ftruncate fround
214 signum cis)
215 (:documentation "Vectorization of numerical functions"))
218 #| ;; some of this goes back in, but not all of it?
219 (defpackage :lisp-stat-linalg
220 (:use :common-lisp
221 :cffi
222 :lisp-matrix
223 :lisp-stat-math
224 :lisp-stat-types
225 :lisp-stat-float
226 :lisp-stat-compound-data)
227 (:shadowing-import-from :lisp-stat-math
228 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
229 asin acos atan sinh cosh tanh asinh acosh atanh float random
230 truncate floor ceiling round minusp zerop plusp evenp oddp
231 < <= = /= >= > complex conjugate realpart imagpart phase
232 min max logand logior logxor lognot ffloor fceiling
233 ftruncate fround signum cis)
234 (:export chol-decomp lu-decomp lu-solve determinant inverse
235 sv-decomp qr-decomp rcondest make-rotation spline
236 kernel-dens kernel-smooth
237 fft make-sweep-matrix sweep-operator ax+y eigen
239 check-real ;; for optimize
241 covariance-matrix matrix print-matrix solve
242 backsolve eigenvalues eigenvectors accumulate cumsum combine
243 lowess))
250 (defpackage :lisp-stat-data
251 (:documentation "Data management, integration, I/O, and other data technologies.")
252 (:nicknames :ls-data)
253 (:use :common-lisp
254 :lisp-stat-object-system
255 :lisp-stat-config
256 :lisp-stat-types
257 :lisp-stat-compound-data)
258 (:shadowing-import-from :lisp-stat-object-system
259 slot-value call-method call-next-method)
260 (:export open-file-dialog read-data-file read-data-columns load-data
261 load-example *variables* *ask-on-redefine*
262 def variables savevar undef))
264 (defpackage :lisp-stat-descriptive-statistics
265 (:use :common-lisp
266 :lisp-stat-data
267 :lisp-stat-math
268 :lisp-stat-compound-data
269 :lisp-matrix
270 :lisp-stat-basics)
271 (:shadowing-import-from :lisp-stat-math ;; life is a vector!
272 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
273 asin acos atan sinh cosh tanh asinh acosh atanh float random
274 truncate floor ceiling round minusp zerop plusp evenp oddp
275 < <= = /= >= > ;; complex
276 conjugate realpart imagpart phase
277 min max logand logior logxor lognot ffloor fceiling
278 ftruncate fround signum cis)
279 (:export standard-deviation quantile median interquartile-range
280 fivnum sample))
283 (defpackage :lisp-stat-regression-linear
284 (:use :common-lisp
285 :lisp-matrix
286 :lisp-stat-object-system
287 :lisp-stat-basics
288 :lisp-stat-compound-data
290 :lisp-stat-math
291 :lisp-stat-descriptive-statistics
294 (:shadowing-import-from :lisp-stat-object-system
295 slot-value call-method call-next-method)
297 (:shadowing-import-from :lisp-stat-math
298 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
299 asin acos atan sinh cosh tanh asinh acosh atanh float random
300 truncate floor ceiling round minusp zerop plusp evenp oddp
301 < <= = /= >= > ;; complex
302 conjugate realpart imagpart phase
303 min max logand logior logxor lognot ffloor fceiling
304 ftruncate fround signum cis)
306 (:export regression-model regression-model-proto x y intercept
307 ;; sweep-matrix
308 basis weights included
309 total-sum-of-squares residual-sum-of-squares
310 predictor-names response-name case-labels
311 ;; functions for helpers
312 lm xtxinv
315 (defpackage :lisp-stat
316 (:documentation "Experimentation package for LispStat. Serious
317 work should be packaged up elsewhere for reproducibility. By this
318 I mean, creating a data/analytics/analysis package with the
319 minimal set of objects required.")
320 (:use :common-lisp
321 :lisp-stat-object-system
322 :lisp-stat-compound-data
323 :lisp-stat-probability
324 :lisp-stat-types
325 :lisp-stat-float
326 :lisp-stat-basics
327 :lisp-stat-data
328 :lisp-stat-math
329 :lisp-matrix ;; conversion to a more robust linalg approach
330 :lisp-stat-descriptive-statistics
331 :lisp-stat-regression-linear)
332 (:shadowing-import-from :lisp-stat-object-system
333 slot-value call-method call-next-method)
334 (:shadowing-import-from :lisp-stat-math
335 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
336 asin acos atan sinh cosh tanh asinh acosh atanh float random
337 truncate floor ceiling round minusp zerop plusp evenp oddp
338 < <= = /= >= >
339 ;;complex
340 conjugate realpart imagpart phase
342 min max
343 logand logior logxor lognot
344 ffloor fceiling ftruncate fround
345 signum cis)
346 (:export
347 ;; lsobjects :
348 defproto defproto2
349 defmeth send
351 ;; lstypes :
352 fixnump check-nonneg-fixnum check-one-fixnum
353 check-one-real check-one-number
355 ;; lsmacros:
357 ;; lsfloat :
358 machine-epsilon
360 ;; compound :
361 compound-data-p *compound-data-proto* compound-object-p
362 compound-data-seq compound-data-length
363 element-list element-seq
364 sort-data order rank
365 recursive-map-elements map-elements
366 repeat
367 check-sequence
368 get-next-element make-next-element set-next-element
369 ;; sequencep
370 iseq
371 ordered-nneg-seq
372 select which
373 difference rseq
375 ;; lsmath.lsp
376 ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
377 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
378 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
379 /= >= > ;; complex
380 conjugate realpart imagpart phase min max
381 logand logior logxor lognot ffloor fceiling ftruncate fround
382 signum cis
384 #| ;; The following need to be re-found in lisp-matrix...
386 ;; matrices.lisp
387 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
388 column-list inner-product outer-product cross-product transpose
389 bind-columns bind-rows
391 ;; linalg.lisp
392 chol-decomp lu-decomp lu-solve determinant inverse
393 sv-decomp qr-decomp rcondest make-rotation spline
394 kernel-dens kernel-smooth
395 fft make-sweep-matrix sweep-operator ax+y eigen
396 check-real
397 covariance-matrix matrix print-matrix solve
398 backsolve eigenvalues eigenvectors accumulate cumsum combine
399 lowess
401 ;; in linalg.lisp, possibly not supported by matlisp
402 spline kernel-dens kernel-smooth
406 ;; optimize.lsp
407 newtonmax nelmeadmax
409 ;; lispstat-macros
410 make-rv-function make-rv-function-1
412 ;; data.lisp
413 open-file-dialog read-data-file read-data-columns load-data
414 load-example *variables* *ask-on-redefine*
415 def variables savevar undef
417 ;; statistics.lsp (descriptions, should probably be moved
418 ;; later...?
419 standard-deviation quantile median interquartile-range
420 fivnum sample
422 ;; probability (dists.lisp)
423 log-gamma set-seed
424 uniform-rand normal-cdf normal-quant normal-dens
425 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
426 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
427 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
428 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
429 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
430 binomial-cdf binomial-quant binomial-pmf binomial-rand
432 ;; Here is where we have a problem -- lispstat core should be core
433 ;; data management and config problems, with packages providing
434 ;; specialized extensions to LispStat, i.e. regression, nonlin
435 ;; regression, bayesian regression via laplace approximation, etc.
437 ;; The following could be considered "recommended packages",
438 ;; similar to the idea of the recommended packages in R. Probably
439 ;; we want them to do the exporting within that package, therefore
440 ;; NOT being able to lock the "data-ish" package, but only the
441 ;; subpackages prior to export.
443 ;; regression.lsp
444 ;; -- linear regressin models.
445 regression-model regression-model-proto x y intercept sweep-matrix
446 basis weights included total-sum-of-squares residual-sum-of-squares
447 predictor-names response-name case-labels
448 lm xtxinv
450 ;; nonlin.lsp
451 ;; -- nonlinear regression models
452 nreg-model nreg-model-proto mean-function theta-hat epsilon
453 count-limit verbose
454 ;; we might need something like xtxinv here? But should be
455 ;; encapsulated, so we use the one in regression.lisp
457 ;; bayes.lsp
458 bayes-model bayes-model-proto bayes-internals))
461 ;;;; PACKAGES FOR USEABILITY
463 (defpackage :lisp-stat-data-examples
464 (:documentation "Example data for unittests, examples, illustrations,")
465 (:use :common-lisp
466 :lisp-stat)
467 (:shadowing-import-from :lisp-stat
468 slot-value call-method call-next-method
470 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
471 asin acos atan sinh cosh tanh asinh acosh atanh float random
472 truncate floor ceiling round minusp zerop plusp evenp oddp
473 < <= = /= >= > > ;; complex
474 conjugate realpart imagpart phase
475 min max logand logior logxor lognot ffloor fceiling
476 ftruncate fround signum cis
478 <= float imagpart)
479 (:export iron aluminum absorbtion
480 diabetes dlabs))
483 (defpackage :lisp-stat-user
484 (:documentation "Experimentation package for LispStat.
485 Serious work should be placed in a similar package elsewhere for
486 reproducibility. But this should hint as to what needs to be
487 done for a user- or analysis-package.")
488 (:nicknames :ls-user)
489 (:use :common-lisp
490 :lisp-matrix
491 :lisp-stat
492 :lisp-stat-data-examples) ;; this last is to have 'things to play with'
493 (:shadowing-import-from :lisp-stat
494 slot-value call-method call-next-method
496 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
497 asin acos atan sinh cosh tanh asinh acosh atanh float random
498 truncate floor ceiling round minusp zerop plusp evenp oddp
499 < <= = /= >= > > ;; complex
500 conjugate realpart imagpart phase
501 min max logand logior logxor lognot ffloor fceiling
502 ftruncate fround signum cis
504 <= float imagpart))
506 (defpackage :lisp-stat-unittests
507 (:use :common-lisp :lift :lisp-stat :lisp-stat-data-examples)
508 (:shadowing-import-from :lisp-stat
509 slot-value call-method call-next-method ;; objects
510 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath
511 asin acos atan sinh cosh tanh asinh acosh atanh float random
512 truncate floor ceiling round minusp zerop plusp evenp oddp
513 < <= = /= >= > ;; complex
514 conjugate realpart imagpart phase
515 min max logand logior logxor lognot ffloor fceiling
516 ftruncate fround signum cis)
517 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard ; exec
518 almost= almost=lists numerical=)) ; compare
520 (defpackage :lisp-stat-data-clos-example
521 (:use :common-lisp
522 :lift :lisp-stat-unittests
523 :lisp-stat-data-examples
524 :lisp-stat-data-clos)
525 (:export absorbtion aluminum iron))
528 (defpackage :lisp-stat-optimize
529 (:use :common-lisp
530 :cffi
531 :lisp-matrix
532 :lisp-stat-ffi-int
533 :lisp-stat-object-system
534 :lisp-stat-types
535 :lisp-stat-compound-data
536 :lisp-stat-math
537 :lisp-stat-float
538 :lisp-stat-basics
540 :lisp-stat-matrix
541 :lisp-stat-linalg-data
542 :lisp-stat-linalg
545 (:shadowing-import-from :lisp-stat-object-system
546 slot-value call-method call-next-method)
547 (:shadowing-import-from :lisp-stat-math
548 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
549 asin acos atan sinh cosh tanh asinh acosh atanh float random
550 truncate floor ceiling round minusp zerop plusp evenp oddp
551 < <= = /= >= > complex conjugate realpart imagpart phase
552 min max logand logior logxor lognot ffloor fceiling
553 ftruncate fround signum cis)
554 (:export
555 ;; derivatives
556 numgrad numhess
558 ;; optimization
559 newtonmax nelmeadmax))