export symbols so we can run unittests.
[CommonLispStat.git] / src / packages.lisp
blob2912ce1fa3800a32092bf7890b1992bb13fc4f5d
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-03-16 21:56:47 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
115 ;; generic container class for data -- if small enough
116 ;; could be value, otherwise might be reference.
117 dataframe-like
118 dataframe-array
119 get-variable-matrix get-variable-vector
120 data-pointer))
123 (defpackage :lisp-stat-regression-linear-clos
124 (:use :common-lisp
125 :lisp-matrix
126 :lisp-stat-data-clos)
127 (:export regression-model))
131 ;;; USER PACKAGES
133 (defpackage :lisp-stat-ffi-int
134 (:use :common-lisp
135 :cffi)
136 (:export ccl-store-integer ccl-store-double ccl-store-ptr
137 get-buf ))
139 (defpackage :lisp-stat-probability
140 (:use :common-lisp
141 :cffi
142 :lisp-stat-ffi-int
143 :lisp-stat-macros)
144 (:export log-gamma set-seed
145 uniform-rand
146 normal-cdf normal-quant normal-dens normal-rand
147 bivnorm-cdf
148 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
149 gamma-cdf gamma-quant gamma-dens gamma-rand
150 chisq-cdf chisq-quant chisq-dens chisq-rand
151 beta-cdf beta-quant beta-dens beta-rand
152 t-cdf t-quant t-dens t-rand
153 f-cdf f-quant f-dens f-rand
154 poisson-cdf poisson-quant poisson-pmf poisson-rand
155 binomial-cdf binomial-quant binomial-pmf binomial-rand))
158 #| removed, replace by lisp-matrix
159 (defpackage :lisp-stat-matrix
160 (:use :common-lisp
161 :cffi
162 :lisp-stat-compound-data)
163 (:export matrixp ;; matrix -- conflicts!
164 num-rows num-cols matmult identity-matrix diagonal
165 row-list column-list inner-product outer-product
166 cross-product
167 ;; transpose bind-columns bind-rows
168 array-data-vector vector-to-array
170 check-matrix check-square-matrix
172 copy-array copy-vector
176 #| replaced by lisp-matrix
177 (defpackage :lisp-stat-linalg-data
178 (:use :common-lisp
179 :cffi
180 :lisp-stat-ffi-int
181 :lisp-stat-types
182 :lisp-stat-compound-data
183 :lisp-stat-matrix)
184 (:export ;; more to add
185 +mode-in+ +mode-re+ +mode-cx+ mode-of
187 la-data-mode la-allocate la-free
189 la-get-double la-put-double
190 la-put-integer
192 la-matrix la-free-matrix la-matrix-to-data la-data-to-matrix
193 la-vector la-free-vector la-vector-to-data la-data-to-vector ))
196 (defpackage :lisp-stat-math
197 (:use :common-lisp
198 :lisp-stat-object-system
199 :lisp-stat-macros
200 :lisp-stat-compound-data
201 :lisp-stat-float)
202 (:shadowing-import-from :lisp-stat-object-system
203 slot-value call-method call-next-method)
204 (:shadow expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
205 asin acos atan sinh cosh tanh asinh acosh atanh float random
206 truncate floor ceiling round minusp zerop plusp evenp oddp
207 < <= = /= >= > ;; complex
208 conjugate realpart imagpart phase
209 min max logand logior logxor lognot ffloor fceiling
210 ftruncate fround signum cis)
211 (:export ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
212 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
213 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
214 /= >= > ;; complex
215 conjugate realpart imagpart phase min max
216 logand logior logxor lognot ffloor fceiling ftruncate fround
217 signum cis)
218 (:documentation "Vectorization of numerical functions"))
221 #| ;; some of this goes back in, but not all of it?
222 (defpackage :lisp-stat-linalg
223 (:use :common-lisp
224 :cffi
225 :lisp-matrix
226 :lisp-stat-math
227 :lisp-stat-types
228 :lisp-stat-float
229 :lisp-stat-compound-data)
230 (:shadowing-import-from :lisp-stat-math
231 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
232 asin acos atan sinh cosh tanh asinh acosh atanh float random
233 truncate floor ceiling round minusp zerop plusp evenp oddp
234 < <= = /= >= > complex conjugate realpart imagpart phase
235 min max logand logior logxor lognot ffloor fceiling
236 ftruncate fround signum cis)
237 (:export chol-decomp lu-decomp lu-solve determinant inverse
238 sv-decomp qr-decomp rcondest make-rotation spline
239 kernel-dens kernel-smooth
240 fft make-sweep-matrix sweep-operator ax+y eigen
242 check-real ;; for optimize
244 covariance-matrix matrix print-matrix solve
245 backsolve eigenvalues eigenvectors accumulate cumsum combine
246 lowess))
253 (defpackage :lisp-stat-data
254 (:documentation "Data management, integration, I/O, and other data technologies.")
255 (:nicknames :ls-data)
256 (:use :common-lisp
257 :lisp-stat-object-system
258 :lisp-stat-config
259 :lisp-stat-types
260 :lisp-stat-compound-data)
261 (:shadowing-import-from :lisp-stat-object-system
262 slot-value call-method call-next-method)
263 (:export open-file-dialog read-data-file read-data-columns load-data
264 load-example *variables* *ask-on-redefine*
265 def variables savevar undef))
267 (defpackage :lisp-stat-descriptive-statistics
268 (:use :common-lisp
269 :lisp-stat-data
270 :lisp-stat-math
271 :lisp-stat-compound-data
272 :lisp-matrix
273 :lisp-stat-basics)
274 (:shadowing-import-from :lisp-stat-math ;; life is a vector!
275 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
276 asin acos atan sinh cosh tanh asinh acosh atanh float random
277 truncate floor ceiling round minusp zerop plusp evenp oddp
278 < <= = /= >= > ;; complex
279 conjugate realpart imagpart phase
280 min max logand logior logxor lognot ffloor fceiling
281 ftruncate fround signum cis)
282 (:export standard-deviation
283 quantile median interquartile-range
284 fivnum sample))
287 (defpackage :lisp-stat-regression-linear
288 (:use :common-lisp
289 :lisp-matrix
290 :lisp-stat-object-system
291 :lisp-stat-basics
292 :lisp-stat-compound-data
293 :lisp-stat-descriptive-statistics
295 :lisp-stat-math
298 (:shadowing-import-from :lisp-stat-object-system
299 slot-value call-method call-next-method)
301 (:shadowing-import-from :lisp-stat-math
302 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
303 asin acos atan sinh cosh tanh asinh acosh atanh float random
304 truncate floor ceiling round minusp zerop plusp evenp oddp
305 < <= = /= >= > ;; complex
306 conjugate realpart imagpart phase
307 min max logand logior logxor lognot ffloor fceiling
308 ftruncate fround signum cis)
310 (:export regression-model regression-model-proto x y intercept
311 ;; sweep-matrix
312 basis weights included
313 total-sum-of-squares residual-sum-of-squares
314 predictor-names response-name case-labels
315 ;; functions for helpers
316 lm xtxinv ))
318 (defpackage :lisp-stat
319 (:documentation "Experimentation package for LispStat. Serious
320 work should be packaged up elsewhere for reproducibility. By this
321 I mean, creating a data/analytics/analysis package with the
322 minimal set of objects required.")
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 :lisp-stat-data-clos
332 :lisp-stat-math
333 :lisp-matrix ;; conversion to a more robust linalg approach
334 :lisp-stat-descriptive-statistics
335 :lisp-stat-regression-linear
336 :cybertiggyr-dsv)
337 (:shadowing-import-from :lisp-stat-object-system
338 slot-value call-method call-next-method)
339 (:shadowing-import-from :lisp-stat-math
340 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
341 asin acos atan sinh cosh tanh asinh acosh atanh float random
342 truncate floor ceiling round minusp zerop plusp evenp oddp
343 < <= = /= >= >
344 ;;complex
345 conjugate realpart imagpart phase
347 min max
348 logand logior logxor lognot
349 ffloor fceiling ftruncate fround
350 signum cis)
351 (:export
352 ;; lsobjects :
353 defproto defproto2
354 defmeth send
356 ;; lstypes :
357 fixnump check-nonneg-fixnum check-one-fixnum
358 check-one-real check-one-number
360 ;; lsmacros:
362 ;; lsfloat :
363 machine-epsilon
365 ;; compound :
366 compound-data-p *compound-data-proto* compound-object-p
367 compound-data-seq compound-data-length
368 element-list element-seq
369 sort-data order rank
370 recursive-map-elements map-elements
371 repeat
372 check-sequence
373 get-next-element make-next-element set-next-element
374 ;; sequencep
375 iseq
376 ordered-nneg-seq
377 select which
378 difference rseq
380 ;; lsmath.lsp
381 ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
382 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
383 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
384 /= >= > ;; complex
385 conjugate realpart imagpart phase min max
386 logand logior logxor lognot ffloor fceiling ftruncate fround
387 signum cis
389 #| ;; The following need to be re-found in lisp-matrix...
391 ;; matrices.lisp
392 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
393 column-list inner-product outer-product cross-product transpose
394 bind-columns bind-rows
396 ;; linalg.lisp
397 chol-decomp lu-decomp lu-solve determinant inverse
398 sv-decomp qr-decomp rcondest make-rotation spline
399 kernel-dens kernel-smooth
400 fft make-sweep-matrix sweep-operator ax+y eigen
401 check-real
402 covariance-matrix matrix print-matrix solve
403 backsolve eigenvalues eigenvectors accumulate cumsum combine
404 lowess
406 ;; in linalg.lisp, possibly not supported by matlisp
407 spline kernel-dens kernel-smooth
411 ;; optimize.lsp
412 newtonmax nelmeadmax
414 ;; lispstat-macros
415 make-rv-function make-rv-function-1
417 ;; data
418 open-file-dialog read-data-file read-data-columns load-data
419 load-example *variables* *ask-on-redefine*
420 def variables savevar undef
422 ;; data-clos
423 dataframe-like
424 dataframe-array
428 ;; statistics.lsp (descriptions, should probably be moved
429 ;; later...?
430 standard-deviation quantile median interquartile-range
431 fivnum sample
433 ;; probability (dists.lisp)
434 log-gamma set-seed
435 uniform-rand normal-cdf normal-quant normal-dens
436 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
437 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
438 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
439 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
440 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
441 binomial-cdf binomial-quant binomial-pmf binomial-rand
443 ;; Here is where we have a problem -- lispstat core should be core
444 ;; data management and config problems, with packages providing
445 ;; specialized extensions to LispStat, i.e. regression, nonlin
446 ;; regression, bayesian regression via laplace approximation, etc.
448 ;; The following could be considered "recommended packages",
449 ;; similar to the idea of the recommended packages in R. Probably
450 ;; we want them to do the exporting within that package, therefore
451 ;; NOT being able to lock the "data-ish" package, but only the
452 ;; subpackages prior to export.
454 ;; regression.lsp
455 ;; -- linear regressin models.
456 regression-model regression-model-proto x y intercept sweep-matrix
457 basis weights included total-sum-of-squares residual-sum-of-squares
458 predictor-names response-name case-labels
459 lm xtxinv
461 ;; nonlin.lsp
462 ;; -- nonlinear regression models
463 nreg-model nreg-model-proto mean-function theta-hat epsilon
464 count-limit verbose
465 ;; we might need something like xtxinv here? But should be
466 ;; encapsulated, so we use the one in regression.lisp
468 ;; bayes.lsp
469 bayes-model bayes-model-proto bayes-internals))
472 ;;;; PACKAGES FOR USEABILITY
474 (defpackage :lisp-stat-data-examples
475 (:documentation "Example data for unittests, examples, illustrations,")
476 (:use :common-lisp
477 :lisp-stat)
478 (:shadowing-import-from :lisp-stat
479 slot-value call-method call-next-method
481 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
482 asin acos atan sinh cosh tanh asinh acosh atanh float random
483 truncate floor ceiling round minusp zerop plusp evenp oddp
484 < <= = /= >= > > ;; complex
485 conjugate realpart imagpart phase
486 min max logand logior logxor lognot ffloor fceiling
487 ftruncate fround signum cis
489 <= float imagpart)
490 (:export iron aluminum absorbtion
491 diabetes dlabs))
494 (defpackage :lisp-stat-user
495 (:documentation "Experimentation package for LispStat.
496 Serious work should be placed in a similar package elsewhere for
497 reproducibility. But this should hint as to what needs to be
498 done for a user- or analysis-package.")
499 (:nicknames :ls-user)
500 (:use :common-lisp
501 :lisp-matrix
502 :lisp-stat
503 :lisp-stat-data-examples) ;; this last is to have 'things to play with'
504 (:shadowing-import-from :lisp-stat
505 slot-value call-method call-next-method
507 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
508 asin acos atan sinh cosh tanh asinh acosh atanh float random
509 truncate floor ceiling round minusp zerop plusp evenp oddp
510 < <= = /= >= > > ;; complex
511 conjugate realpart imagpart phase
512 min max logand logior logxor lognot ffloor fceiling
513 ftruncate fround signum cis
515 <= float imagpart))
517 (defpackage :lisp-stat-unittests
518 (:use :common-lisp :lift :lisp-stat :lisp-stat-data-examples)
519 (:shadowing-import-from :lisp-stat
520 slot-value call-method call-next-method ;; objects
521 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath
522 asin acos atan sinh cosh tanh asinh acosh atanh float random
523 truncate floor ceiling round minusp zerop plusp evenp oddp
524 < <= = /= >= > ;; complex
525 conjugate realpart imagpart phase
526 min max logand logior logxor lognot ffloor fceiling
527 ftruncate fround signum cis)
528 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard ; exec
529 almost= almost=lists numerical=)) ; compare
531 (defpackage :lisp-stat-data-clos-example
532 (:use :common-lisp
533 :lift :lisp-stat-unittests
534 :lisp-stat-data-examples
535 :lisp-stat-data-clos)
536 (:export absorbtion aluminum iron))
539 (defpackage :lisp-stat-optimize
540 (:use :common-lisp
541 :cffi
542 :lisp-matrix
543 :lisp-stat-ffi-int
544 :lisp-stat-object-system
545 :lisp-stat-types
546 :lisp-stat-compound-data
547 :lisp-stat-math
548 :lisp-stat-float
549 :lisp-stat-basics
551 :lisp-stat-matrix
552 :lisp-stat-linalg-data
553 :lisp-stat-linalg
556 (:shadowing-import-from :lisp-stat-object-system
557 slot-value call-method call-next-method)
558 (:shadowing-import-from :lisp-stat-math
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 conjugate realpart imagpart phase
563 min max logand logior logxor lognot ffloor fceiling
564 ftruncate fround signum cis)
565 (:export
566 ;; derivatives
567 numgrad numhess
569 ;; optimization
570 newtonmax nelmeadmax))