package clean up but not done yet.
[CommonLispStat.git] / src / packages.lisp
blob9b73c7768566ac14939d7352d6db44036a8020c9
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2008-11-10 14:52:43 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 (in-package :cl-user)
24 (defpackage :lisp-stat-object-system
25 (:nicknames :ls-objects :lsos)
26 (:use :common-lisp)
27 (:shadow :call-method :call-next-method :slot-value)
28 (:export ls-object objectp *object* kind-of-p make-object
29 *message-hook*
30 *set-slot-hook* slot-value self
31 send call-next-method call-method
32 defmeth defproto instance-slots proto-name))
38 (defpackage :lisp-stat-types
39 (:documentation "Provides some typeing for LispStat, but is clearly
40 a bit incomplete.")
41 (:use :common-lisp)
42 (:export fixnump
43 check-nonneg-fixnum check-one-nonneg-fixnum
44 check-one-fixnum check-one-real check-one-number))
47 ;;; Package Setup
49 (in-package :cl-user)
51 (defpackage :lisp-stat-float
52 (:use :common-lisp)
53 (:export +stat-float-typing+ +stat-cfloat-typing+ +stat-float-template+
54 machine-epsilon base-float makedouble
56 make-base-trans-fun-2 make-base-trans-fun
58 base-log base-exp base-expt base-sqrt base-sin base-cos
59 base-tan base-asin base-acos base-atan base-sinh
60 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
61 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
62 BASE-FROUND BASE-SIGNUM BASE-CIS))
65 (defpackage :lisp-stat-compound-data
66 (:use :common-lisp
67 :lisp-stat-object-system
68 :lisp-stat-types)
69 (:shadowing-import-from :lisp-stat-object-system
70 slot-value
71 call-next-method call-method)
72 (:export compound-data-p *compound-data-proto*
73 compound-object-p
74 compound-data-seq compound-data-length
75 element-list element-seq
76 sort-data order rank
77 recursive-map-elements map-elements repeat
78 check-sequence
79 get-next-element make-next-element set-next-element
80 sequencep iseq ordered-nneg-seq
81 select split-list which
82 difference rseq
83 flatten-list ))
85 (defpackage :lisp-stat-macros
86 (:use :common-lisp
87 :lisp-stat-compound-data)
88 (:export make-rv-function make-rv-function-1))
90 (defpackage :lisp-stat-basics
91 (:use :common-lisp
92 :lisp-stat-object-system
93 :lisp-stat-types
94 :lisp-stat-float
95 :lisp-stat-macros
96 :lisp-stat-compound-data)
97 (:shadowing-import-from :lisp-stat-object-system
98 slot-value call-method call-next-method)
99 (:export permute-array sum prod count-elements mean
100 if-else sample))
104 (defpackage :lisp-stat-float
105 (:use :common-lisp)
106 (:export +stat-float-typing+ +stat-cfloat-typing+ +stat-float-template+
107 machine-epsilon base-float makedouble
109 make-base-trans-fun-2 make-base-trans-fun
111 BASE-LOG BASE-EXP BASE-EXPT BASE-SQRT BASE-SIN BASE-COS
112 BASE-TAN BASE-ASIN BASE-ACOS BASE-ATAN BASE-SINH
113 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
114 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
115 BASE-FROUND BASE-SIGNUM BASE-CIS))
117 ;;;
119 (defpackage :lisp-stat-macros
120 (:use :common-lisp
121 :lisp-stat-compound-data)
122 (:export make-rv-function make-rv-function-1))
124 ;;; NEW CLOS STRUCTURE
126 (defpackage :lisp-stat-data-clos
127 (:use :common-lisp
128 :lisp-matrix)
129 (:export get-variable-matrix get-variable-vector
130 ;; generic container class for data -- if small enough
131 ;; could be value, otherwise might be reference.
132 data-pointer))
134 (defpackage :lisp-stat-regression-linear-clos
135 (:use :common-lisp
136 :lisp-matrix
137 :lisp-stat-data-clos)
138 (:export regression-model))
142 ;;; USER PACKAGES
144 (defpackage :lisp-stat-ffi-int
145 (:use :common-lisp
146 :cffi)
147 (:export ccl-store-integer ccl-store-double ccl-store-ptr
148 get-buf ))
150 (defpackage :lisp-stat-probability
151 (:use :common-lisp
152 :cffi
153 :lisp-stat-ffi-int
154 :lisp-stat-macros)
155 (:export log-gamma set-seed
156 uniform-rand
157 normal-cdf normal-quant normal-dens normal-rand
158 bivnorm-cdf
159 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
160 gamma-cdf gamma-quant gamma-dens gamma-rand
161 chisq-cdf chisq-quant chisq-dens chisq-rand
162 beta-cdf beta-quant beta-dens beta-rand
163 t-cdf t-quant t-dens t-rand
164 f-cdf f-quant f-dens f-rand
165 poisson-cdf poisson-quant poisson-pmf poisson-rand
166 binomial-cdf binomial-quant binomial-pmf binomial-rand))
170 (defpackage :lisp-stat-matrix
171 (:use :common-lisp
172 :cffi
173 :lisp-stat-compound-data)
174 (:export matrixp ;; matrix -- conflicts!
175 num-rows num-cols matmult identity-matrix diagonal
176 row-list column-list inner-product outer-product
177 cross-product transpose bind-columns bind-rows
178 array-data-vector vector-to-array
180 check-matrix check-square-matrix
182 copy-array copy-vector
185 (defpackage :lisp-stat-linalg-data
186 (:use :common-lisp
187 :cffi
188 :lisp-stat-ffi-int
189 :lisp-stat-types
190 :lisp-stat-compound-data
191 :lisp-stat-matrix)
192 (:export ;; more to add
193 +mode-in+ +mode-re+ +mode-cx+ mode-of
195 la-data-mode la-allocate la-free
197 la-get-double la-put-double
198 la-put-integer
200 la-matrix la-free-matrix la-matrix-to-data la-data-to-matrix
201 la-vector la-free-vector la-vector-to-data la-data-to-vector ))
204 (defpackage :lisp-stat-math
205 (:use :common-lisp
206 :lisp-stat-object-system
207 :lisp-stat-macros
208 :lisp-stat-compound-data
209 :lisp-stat-float)
210 (:shadowing-import-from :lisp-stat-object-system
211 slot-value call-method call-next-method)
212 (:shadow expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
213 asin acos atan sinh cosh tanh asinh acosh atanh float random
214 truncate floor ceiling round minusp zerop plusp evenp oddp
215 < <= = /= >= > ;; complex
216 conjugate realpart imagpart phase
217 min max logand logior logxor lognot ffloor fceiling
218 ftruncate fround signum cis)
219 (:export ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
220 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
221 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
222 /= >= > ;; complex
223 conjugate realpart imagpart phase min max
224 logand logior logxor lognot ffloor fceiling ftruncate fround
225 signum cis)
226 (:documentation "Vectorization of numerical functions"))
229 (defpackage :lisp-stat-linalg
230 (:use :common-lisp
231 :cffi
232 :lisp-stat-ffi-int
233 :lisp-stat-math
234 :lisp-stat-types
235 :lisp-stat-float
236 :lisp-stat-compound-data
237 :lisp-stat-linalg-data
238 :lisp-stat-matrix)
239 (:shadowing-import-from :lisp-stat-math
240 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
241 asin acos atan sinh cosh tanh asinh acosh atanh float random
242 truncate floor ceiling round minusp zerop plusp evenp oddp
243 < <= = /= >= > complex conjugate realpart imagpart phase
244 min max logand logior logxor lognot ffloor fceiling
245 ftruncate fround signum cis)
246 (:export chol-decomp lu-decomp lu-solve determinant inverse
247 sv-decomp qr-decomp rcondest make-rotation spline
248 kernel-dens kernel-smooth
249 fft make-sweep-matrix sweep-operator ax+y eigen
251 check-real ;; for optimize
253 covariance-matrix matrix print-matrix solve
254 backsolve eigenvalues eigenvectors accumulate cumsum combine
255 lowess))
258 (defpackage :lisp-stat-config
259 (:use :common-lisp)
260 (:export *default-path*
261 *lsos-files* *basic-files* *ls-files*
262 *lispstat-data-dir* *lispstat-examples-dir*))
265 (defpackage :lisp-stat-data
266 (:documentation "Data management, integration, I/O, and other data technologies.")
267 (:nicknames :ls-data)
268 (:use :common-lisp
269 :lisp-stat-object-system
270 :lisp-stat-config
271 :lisp-stat-types
272 :lisp-stat-compound-data)
273 (:shadowing-import-from :lisp-stat-object-system
274 slot-value call-method call-next-method)
275 (:export open-file-dialog read-data-file read-data-columns load-data
276 load-example *variables* *ask-on-redefine*
277 def variables savevar undef))
279 (defpackage :lisp-stat-descriptive-statistics
280 (:use :common-lisp
281 :lisp-stat-data
282 :lisp-stat-math
283 :lisp-stat-compound-data
284 :lisp-stat-matrix
285 :lisp-stat-linalg-data
286 :lisp-stat-linalg
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 quantile median interquartile-range
297 fivnum sample))
300 (defpackage :lisp-stat-regression-linear
301 (:use :common-lisp
302 :lisp-stat-object-system
303 :lisp-stat-basics
304 :lisp-stat-compound-data
305 :lisp-stat-math
306 :lisp-stat-matrix
307 :lisp-stat-linalg
308 :lisp-stat-descriptive-statistics)
309 (:shadowing-import-from :lisp-stat-object-system
310 slot-value call-method call-next-method)
311 (:shadowing-import-from :lisp-stat-math
312 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
313 asin acos atan sinh cosh tanh asinh acosh atanh float random
314 truncate floor ceiling round minusp zerop plusp evenp oddp
315 < <= = /= >= > ;; complex
316 conjugate realpart imagpart phase
317 min max logand logior logxor lognot ffloor fceiling
318 ftruncate fround signum cis)
319 (:export regression-model regression-model-proto x y intercept sweep-matrix
320 basis weights included total-sum-of-squares residual-sum-of-squares
321 predictor-names response-name case-labels))
323 (defpackage :lisp-stat
324 (:documentation "Experimentation package for LispStat. Serious
325 work should be packaged up elsewhere for reproducibility. By this
326 I mean, creating a data/analytics/analysis package with the
327 minimal set of objects required.")
328 (:use :common-lisp
329 :lisp-stat-object-system
330 :lisp-stat-compound-data
331 :lisp-stat-probability
332 :lisp-stat-types
333 :lisp-stat-float
334 :lisp-stat-basics
335 :lisp-stat-data
336 :lisp-stat-math
337 :lisp-stat-matrix
338 :lisp-stat-linalg
339 :lisp-stat-descriptive-statistics
340 :lisp-stat-regression-linear)
341 (:shadowing-import-from :lisp-stat-object-system
342 slot-value 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 < <= = /= >= > ;;complex
348 conjugate realpart imagpart phase
349 min max logand logior logxor lognot ffloor fceiling
350 ftruncate fround 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 iseq
375 ordered-nneg-seq
376 select which
377 difference rseq
379 ;; lsmath.lsp
380 ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
381 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
382 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
383 /= >= > ;; complex
384 conjugate realpart imagpart phase min max
385 logand logior logxor lognot ffloor fceiling ftruncate fround
386 signum cis
388 ;; matrices.lisp
389 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
390 column-list inner-product outer-product cross-product transpose
391 bind-columns bind-rows
393 ;; linalg.lisp
394 chol-decomp lu-decomp lu-solve determinant inverse
395 sv-decomp qr-decomp rcondest make-rotation spline
396 kernel-dens kernel-smooth
397 fft make-sweep-matrix sweep-operator ax+y eigen
398 check-real
399 covariance-matrix matrix print-matrix solve
400 backsolve eigenvalues eigenvectors accumulate cumsum combine
401 lowess
403 ;; in linalg.lisp, possibly not supported by matlisp
404 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
418 standard-deviation quantile median interquartile-range
419 fivnum sample
421 ;; dists
422 log-gamma set-seed
423 uniform-rand normal-cdf normal-quant normal-dens
424 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
425 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
426 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
427 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
428 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
429 binomial-cdf binomial-quant binomial-pmf binomial-rand
431 ;;; Here is where we have a problem -- lispstat core should be core
432 ;;; data management and config problems, with packages providing
433 ;;; specialized extensions to LispStat, i.e. regression, nonlin
434 ;;; regression, bayesian regression via laplace approximation, etc.
436 ;;; The following could be considered "recommended packages", similar
437 ;;; to the idea of the recommended packages in R.
439 ;; regression.lsp
440 regression-model regression-model-proto x y intercept sweep-matrix
441 basis weights included total-sum-of-squares residual-sum-of-squares
442 predictor-names response-name case-labels
444 ;; nonlin.lsp
445 nreg-model nreg-model-proto mean-function theta-hat epsilon
446 count-limit verbose
448 ;; bayes.lsp
449 bayes-model bayes-model-proto bayes-internals))
452 ;;;; PACKAGES FOR USEABILITY
454 (defpackage :lisp-stat-data-examples
455 (:documentation "Example data for unittests, examples, illustrations,")
456 (:use :common-lisp
457 :lisp-stat)
458 (:shadowing-import-from :lisp-stat
459 slot-value call-method call-next-method
461 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
462 asin acos atan sinh cosh tanh asinh acosh atanh float random
463 truncate floor ceiling round minusp zerop plusp evenp oddp
464 < <= = /= >= > > ;; complex
465 conjugate realpart imagpart phase
466 min max logand logior logxor lognot ffloor fceiling
467 ftruncate fround signum cis
469 <= float imagpart)
470 (:export iron aluminum absorbtion
471 diabetes dlabs))
474 (defpackage :lisp-stat-user
475 (:documentation "Experimentation package for LispStat.
476 Serious work should be placed in a similar package elsewhere for
477 reproducibility. But this should hint as to what needs to be
478 done for a user- or analysis-package.")
479 (:nicknames :ls-user)
480 (:use :common-lisp
481 :lisp-stat
482 :lisp-stat-data-examples) ;; this last is to have 'things to play with'
483 (:shadowing-import-from :lisp-stat
484 slot-value call-method call-next-method
486 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
487 asin acos atan sinh cosh tanh asinh acosh atanh float random
488 truncate floor ceiling round minusp zerop plusp evenp oddp
489 < <= = /= >= > > ;; complex
490 conjugate realpart imagpart phase
491 min max logand logior logxor lognot ffloor fceiling
492 ftruncate fround signum cis
494 <= float imagpart))
496 (defpackage :lisp-stat-unittests
497 (:use :common-lisp :lift :lisp-stat :lisp-stat-data-examples)
498 (:shadowing-import-from :lisp-stat
499 slot-value call-method call-next-method ;; objects
500 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath
501 asin acos atan sinh cosh tanh asinh acosh atanh float random
502 truncate floor ceiling round minusp zerop plusp evenp oddp
503 < <= = /= >= > ;; complex
504 conjugate realpart imagpart phase
505 min max logand logior logxor lognot ffloor fceiling
506 ftruncate fround signum cis)
507 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard ; exec
508 almost= almost=lists numerical=)) ; compare
510 (defpackage :lisp-stat-data-clos-example
511 (:use :common-lisp
512 :lift :lisp-stat-unittests
513 :lisp-stat-data-examples
514 :lisp-stat-data-clos)
515 (:export absorbtion aluminum iron))