STARTING LISP-MATRIX SWAP IN! NEXT FEW EONS! ALL IS BROKEN!
[CommonLispStat.git] / src / packages.lisp
blob028f06c0dc115c04ff49785934dd1d9641db3317
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2008-11-25 08:31:31 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
81 iseq ordered-nneg-seq
82 select split-list which
83 difference rseq
84 flatten-list ))
86 (defpackage :lisp-stat-macros
87 (:use :common-lisp
88 :lisp-stat-compound-data)
89 (:export make-rv-function make-rv-function-1))
91 (defpackage :lisp-stat-basics
92 (:use :common-lisp
93 :lisp-stat-object-system
94 :lisp-stat-types
95 :lisp-stat-float
96 :lisp-stat-macros
97 :lisp-stat-compound-data)
98 (:shadowing-import-from :lisp-stat-object-system
99 slot-value call-method call-next-method)
100 (:export permute-array sum prod count-elements mean
101 if-else sample))
105 (defpackage :lisp-stat-float
106 (:use :common-lisp)
107 (:export +stat-float-typing+ +stat-cfloat-typing+ +stat-float-template+
108 machine-epsilon base-float makedouble
110 make-base-trans-fun-2 make-base-trans-fun
112 BASE-LOG BASE-EXP BASE-EXPT BASE-SQRT BASE-SIN BASE-COS
113 BASE-TAN BASE-ASIN BASE-ACOS BASE-ATAN BASE-SINH
114 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
115 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
116 BASE-FROUND BASE-SIGNUM BASE-CIS))
118 ;;;
120 (defpackage :lisp-stat-macros
121 (:use :common-lisp
122 :lisp-stat-compound-data)
123 (:export make-rv-function make-rv-function-1))
125 ;;; NEW CLOS STRUCTURE
127 (defpackage :lisp-stat-data-clos
128 (:use :common-lisp
129 :lisp-matrix)
130 (:export get-variable-matrix get-variable-vector
131 ;; generic container class for data -- if small enough
132 ;; could be value, otherwise might be reference.
133 data-pointer))
135 (defpackage :lisp-stat-regression-linear-clos
136 (:use :common-lisp
137 :lisp-matrix
138 :lisp-stat-data-clos)
139 (:export regression-model))
143 ;;; USER PACKAGES
145 (defpackage :lisp-stat-ffi-int
146 (:use :common-lisp
147 :cffi)
148 (:export ccl-store-integer ccl-store-double ccl-store-ptr
149 get-buf ))
151 (defpackage :lisp-stat-probability
152 (:use :common-lisp
153 :cffi
154 :lisp-stat-ffi-int
155 :lisp-stat-macros)
156 (:export log-gamma set-seed
157 uniform-rand
158 normal-cdf normal-quant normal-dens normal-rand
159 bivnorm-cdf
160 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
161 gamma-cdf gamma-quant gamma-dens gamma-rand
162 chisq-cdf chisq-quant chisq-dens chisq-rand
163 beta-cdf beta-quant beta-dens beta-rand
164 t-cdf t-quant t-dens t-rand
165 f-cdf f-quant f-dens f-rand
166 poisson-cdf poisson-quant poisson-pmf poisson-rand
167 binomial-cdf binomial-quant binomial-pmf binomial-rand))
171 (defpackage :lisp-stat-matrix
172 (:use :common-lisp
173 :cffi
174 :lisp-stat-compound-data)
175 (:export matrixp ;; matrix -- conflicts!
176 num-rows num-cols matmult identity-matrix diagonal
177 row-list column-list inner-product outer-product
178 cross-product transpose bind-columns bind-rows
179 array-data-vector vector-to-array
181 check-matrix check-square-matrix
183 copy-array copy-vector
186 (defpackage :lisp-stat-linalg-data
187 (:use :common-lisp
188 :cffi
189 :lisp-stat-ffi-int
190 :lisp-stat-types
191 :lisp-stat-compound-data
192 :lisp-stat-matrix)
193 (:export ;; more to add
194 +mode-in+ +mode-re+ +mode-cx+ mode-of
196 la-data-mode la-allocate la-free
198 la-get-double la-put-double
199 la-put-integer
201 la-matrix la-free-matrix la-matrix-to-data la-data-to-matrix
202 la-vector la-free-vector la-vector-to-data la-data-to-vector ))
205 (defpackage :lisp-stat-math
206 (:use :common-lisp
207 :lisp-stat-object-system
208 :lisp-stat-macros
209 :lisp-stat-compound-data
210 :lisp-stat-float)
211 (:shadowing-import-from :lisp-stat-object-system
212 slot-value call-method call-next-method)
213 (:shadow expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
214 asin acos atan sinh cosh tanh asinh acosh atanh float random
215 truncate floor ceiling round minusp zerop plusp evenp oddp
216 < <= = /= >= > ;; complex
217 conjugate realpart imagpart phase
218 min max logand logior logxor lognot ffloor fceiling
219 ftruncate fround signum cis)
220 (:export ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
221 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
222 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
223 /= >= > ;; complex
224 conjugate realpart imagpart phase min max
225 logand logior logxor lognot ffloor fceiling ftruncate fround
226 signum cis)
227 (:documentation "Vectorization of numerical functions"))
230 (defpackage :lisp-stat-linalg
231 (:use :common-lisp
232 :cffi
233 :lisp-stat-ffi-int
234 :lisp-stat-math
235 :lisp-stat-types
236 :lisp-stat-float
237 :lisp-stat-compound-data
238 :lisp-stat-linalg-data
239 :lisp-stat-matrix)
240 (:shadowing-import-from :lisp-stat-math
241 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
242 asin acos atan sinh cosh tanh asinh acosh atanh float random
243 truncate floor ceiling round minusp zerop plusp evenp oddp
244 < <= = /= >= > complex conjugate realpart imagpart phase
245 min max logand logior logxor lognot ffloor fceiling
246 ftruncate fround signum cis)
247 (:export chol-decomp lu-decomp lu-solve determinant inverse
248 sv-decomp qr-decomp rcondest make-rotation spline
249 kernel-dens kernel-smooth
250 fft make-sweep-matrix sweep-operator ax+y eigen
252 check-real ;; for optimize
254 covariance-matrix matrix print-matrix solve
255 backsolve eigenvalues eigenvectors accumulate cumsum combine
256 lowess))
261 (defpackage :lisp-stat-data
262 (:documentation "Data management, integration, I/O, and other data technologies.")
263 (:nicknames :ls-data)
264 (:use :common-lisp
265 :lisp-stat-object-system
266 :lisp-stat-config
267 :lisp-stat-types
268 :lisp-stat-compound-data)
269 (:shadowing-import-from :lisp-stat-object-system
270 slot-value call-method call-next-method)
271 (:export open-file-dialog read-data-file read-data-columns load-data
272 load-example *variables* *ask-on-redefine*
273 def variables savevar undef))
275 (defpackage :lisp-stat-descriptive-statistics
276 (:use :common-lisp
277 :lisp-stat-data
278 :lisp-stat-math
279 :lisp-stat-compound-data
280 :lisp-matrix
282 ;; redone within lisp-matrix -- will need to have a package for
283 ;; any leftovers...
284 :lisp-stat-matrix
285 :lisp-stat-linalg-data
286 :lisp-stat-linalg
288 :lisp-stat-basics)
289 (:shadowing-import-from :lisp-stat-math ;; life is a vector!
290 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
291 asin acos atan sinh cosh tanh asinh acosh atanh float random
292 truncate floor ceiling round minusp zerop plusp evenp oddp
293 < <= = /= >= > ;; complex
294 conjugate realpart imagpart phase
295 min max logand logior logxor lognot ffloor fceiling
296 ftruncate fround signum cis)
297 (:export standard-deviation quantile median interquartile-range
298 fivnum sample))
301 (defpackage :lisp-stat-regression-linear
302 (:use :common-lisp
303 :lisp-stat-object-system
304 :lisp-stat-basics
305 :lisp-stat-compound-data
306 :lisp-stat-math
307 :lisp-matrix
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-matrix ;; conversion to a more robust linalg approach
338 :lisp-stat-descriptive-statistics
339 :lisp-stat-regression-linear)
340 (:shadowing-import-from :lisp-stat-object-system
341 slot-value call-method call-next-method)
342 (:shadowing-import-from :lisp-stat-math
343 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
344 asin acos atan sinh cosh tanh asinh acosh atanh float random
345 truncate floor ceiling round minusp zerop plusp evenp oddp
346 < <= = /= >= >
347 ;;complex
348 conjugate realpart imagpart phase
350 min max
351 logand logior logxor lognot
352 ffloor fceiling ftruncate fround
353 signum cis)
354 (:export
355 ;; lsobjects :
356 defproto defproto2
357 defmeth send
359 ;; lstypes :
360 fixnump check-nonneg-fixnum check-one-fixnum
361 check-one-real check-one-number
363 ;; lsmacros:
365 ;; lsfloat :
366 machine-epsilon
368 ;; compound :
369 compound-data-p *compound-data-proto* compound-object-p
370 compound-data-seq compound-data-length
371 element-list element-seq
372 sort-data order rank
373 recursive-map-elements map-elements
374 repeat
375 check-sequence
376 get-next-element make-next-element set-next-element
377 ;; sequencep
378 iseq
379 ordered-nneg-seq
380 select which
381 difference rseq
383 ;; lsmath.lsp
384 ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
385 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
386 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
387 /= >= > ;; complex
388 conjugate realpart imagpart phase min max
389 logand logior logxor lognot ffloor fceiling ftruncate fround
390 signum cis
393 ;; The following need to be re-found in lisp-matrix...
394 ;; matrices.lisp
395 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
396 column-list inner-product outer-product cross-product transpose
397 bind-columns bind-rows
399 ;; linalg.lisp
400 chol-decomp lu-decomp lu-solve determinant inverse
401 sv-decomp qr-decomp rcondest make-rotation spline
402 kernel-dens kernel-smooth
403 fft make-sweep-matrix sweep-operator ax+y eigen
404 check-real
405 covariance-matrix matrix print-matrix solve
406 backsolve eigenvalues eigenvectors accumulate cumsum combine
407 lowess
409 ;; in linalg.lisp, possibly not supported by matlisp
410 spline kernel-dens kernel-smooth
414 ;; optimize.lsp
415 newtonmax nelmeadmax
417 ;; lispstat-macros
418 make-rv-function make-rv-function-1
420 ;; data.lisp
421 open-file-dialog read-data-file read-data-columns load-data
422 load-example *variables* *ask-on-redefine*
423 def variables savevar undef
425 ;; statistics.lsp (descriptions, should probably be moved
426 ;; later...?
427 standard-deviation quantile median interquartile-range
428 fivnum sample
430 ;; probability (dists.lisp)
431 log-gamma set-seed
432 uniform-rand normal-cdf normal-quant normal-dens
433 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
434 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
435 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
436 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
437 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
438 binomial-cdf binomial-quant binomial-pmf binomial-rand
440 ;; Here is where we have a problem -- lispstat core should be core
441 ;; data management and config problems, with packages providing
442 ;; specialized extensions to LispStat, i.e. regression, nonlin
443 ;; regression, bayesian regression via laplace approximation, etc.
445 ;; The following could be considered "recommended packages",
446 ;; similar to the idea of the recommended packages in R. Probably
447 ;; we want them to do the exporting within that package, therefore
448 ;; NOT being able to lock the "data-ish" package, but only the
449 ;; subpackages prior to export.
451 ;; regression.lsp
452 regression-model regression-model-proto x y intercept sweep-matrix
453 basis weights included total-sum-of-squares residual-sum-of-squares
454 predictor-names response-name case-labels
456 ;; nonlin.lsp
457 nreg-model nreg-model-proto mean-function theta-hat epsilon
458 count-limit verbose
460 ;; bayes.lsp
461 bayes-model bayes-model-proto bayes-internals))
464 ;;;; PACKAGES FOR USEABILITY
466 (defpackage :lisp-stat-data-examples
467 (:documentation "Example data for unittests, examples, illustrations,")
468 (:use :common-lisp
469 :lisp-stat)
470 (:shadowing-import-from :lisp-stat
471 slot-value call-method call-next-method
473 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
474 asin acos atan sinh cosh tanh asinh acosh atanh float random
475 truncate floor ceiling round minusp zerop plusp evenp oddp
476 < <= = /= >= > > ;; complex
477 conjugate realpart imagpart phase
478 min max logand logior logxor lognot ffloor fceiling
479 ftruncate fround signum cis
481 <= float imagpart)
482 (:export iron aluminum absorbtion
483 diabetes dlabs))
486 (defpackage :lisp-stat-user
487 (:documentation "Experimentation package for LispStat.
488 Serious work should be placed in a similar package elsewhere for
489 reproducibility. But this should hint as to what needs to be
490 done for a user- or analysis-package.")
491 (:nicknames :ls-user)
492 (:use :common-lisp
493 :lisp-matrix
494 :lisp-stat
495 :lisp-stat-data-examples) ;; this last is to have 'things to play with'
496 (:shadowing-import-from :lisp-stat
497 slot-value call-method call-next-method
499 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
500 asin acos atan sinh cosh tanh asinh acosh atanh float random
501 truncate floor ceiling round minusp zerop plusp evenp oddp
502 < <= = /= >= > > ;; complex
503 conjugate realpart imagpart phase
504 min max logand logior logxor lognot ffloor fceiling
505 ftruncate fround signum cis
507 <= float imagpart))
509 (defpackage :lisp-stat-unittests
510 (:use :common-lisp :lift :lisp-stat :lisp-stat-data-examples)
511 (:shadowing-import-from :lisp-stat
512 slot-value call-method call-next-method ;; objects
513 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath
514 asin acos atan sinh cosh tanh asinh acosh atanh float random
515 truncate floor ceiling round minusp zerop plusp evenp oddp
516 < <= = /= >= > ;; complex
517 conjugate realpart imagpart phase
518 min max logand logior logxor lognot ffloor fceiling
519 ftruncate fround signum cis)
520 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard ; exec
521 almost= almost=lists numerical=)) ; compare
523 (defpackage :lisp-stat-data-clos-example
524 (:use :common-lisp
525 :lift :lisp-stat-unittests
526 :lisp-stat-data-examples
527 :lisp-stat-data-clos)
528 (:export absorbtion aluminum iron))