lisp, not lsp.
[CommonLispStat.git] / src / packages.lisp
blob17e5a31d4cef365ca894f0e4f2b94c0db659e4ba
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2008-11-04 07:53:06 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))
107 (defpackage :lisp-stat-float
108 (:use :common-lisp)
109 (:export +stat-float-typing+ +stat-cfloat-typing+ +stat-float-template+
110 machine-epsilon base-float makedouble
112 make-base-trans-fun-2 make-base-trans-fun
114 BASE-LOG BASE-EXP BASE-EXPT BASE-SQRT BASE-SIN BASE-COS
115 BASE-TAN BASE-ASIN BASE-ACOS BASE-ATAN BASE-SINH
116 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
117 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
118 BASE-FROUND BASE-SIGNUM BASE-CIS))
120 ;;;
122 (defpackage :lisp-stat-macros
123 (:use :common-lisp
124 :lisp-stat-compound-data)
125 (:export make-rv-function make-rv-function-1))
127 ;;; NEW CLOS STRUCTURE
129 (defpackage :lisp-stat-data-clos
130 (:use :common-lisp
131 :lisp-matrix)
132 (:export get-variable-matrix get-variable-vector
133 ;; generic container class for data -- if small enough
134 ;; could be value, otherwise might be reference.
135 data-pointer))
137 (defpackage :lisp-stat-regression-linear-clos
138 (:use :common-lisp
139 :lisp-matrix
140 :lisp-stat-data-clos)
141 (:export regression-model))
145 ;;; USER PACKAGES
147 (defpackage :lisp-stat-ffi-int
148 (:use :common-lisp
149 :cffi)
150 (:export ccl-store-integer ccl-store-double ccl-store-ptr
151 get-buf ))
153 (defpackage :lisp-stat-probability
154 (:use :common-lisp
155 :cffi
156 :lisp-stat-ffi-int
157 :lisp-stat-macros)
158 (:export log-gamma set-seed
159 uniform-rand
160 normal-cdf normal-quant normal-dens normal-rand
161 bivnorm-cdf
162 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
163 gamma-cdf gamma-quant gamma-dens gamma-rand
164 chisq-cdf chisq-quant chisq-dens chisq-rand
165 beta-cdf beta-quant beta-dens beta-rand
166 t-cdf t-quant t-dens t-rand
167 f-cdf f-quant f-dens f-rand
168 poisson-cdf poisson-quant poisson-pmf poisson-rand
169 binomial-cdf binomial-quant binomial-pmf binomial-rand))
173 (defpackage :lisp-stat-matrix
174 (:use :common-lisp
175 :cffi
176 :lisp-stat-compound-data)
177 (:export matrixp ;; matrix -- conflicts!
178 num-rows num-cols matmult identity-matrix diagonal
179 row-list column-list inner-product outer-product
180 cross-product transpose bind-columns bind-rows
181 array-data-vector vector-to-array
183 check-matrix check-square-matrix
185 copy-array copy-vector
188 (defpackage :lisp-stat-linalg-data
189 (:use :common-lisp
190 :cffi
191 :lisp-stat-ffi-int
192 :lisp-stat-types
193 :lisp-stat-compound-data
194 :lisp-stat-matrix)
195 (:export ;; more to add
196 +mode-in+ +mode-re+ +mode-cx+ mode-of
198 la-data-mode la-allocate la-free
200 la-get-double la-put-double
201 la-put-integer
203 la-matrix la-free-matrix la-matrix-to-data la-data-to-matrix
204 la-vector la-free-vector la-vector-to-data la-data-to-vector ))
207 (defpackage :lisp-stat-math
208 (:use :common-lisp
209 :lisp-stat-object-system
210 :lisp-stat-macros
211 :lisp-stat-compound-data
212 :lisp-stat-float)
213 (:shadowing-import-from :lisp-stat-object-system
214 slot-value call-method call-next-method)
215 (:shadow expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
216 asin acos atan sinh cosh tanh asinh acosh atanh float random
217 truncate floor ceiling round minusp zerop plusp evenp oddp
218 < <= = /= >= > ;; complex
219 conjugate realpart imagpart phase
220 min max logand logior logxor lognot ffloor fceiling
221 ftruncate fround signum cis)
222 (:export ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
223 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
224 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
225 /= >= > ;; complex
226 conjugate realpart imagpart phase min max
227 logand logior logxor lognot ffloor fceiling ftruncate fround
228 signum cis)
229 (:documentation "Vectorization of numerical functions"))
232 (defpackage :lisp-stat-linalg
233 (:use :common-lisp
234 :cffi
235 :lisp-stat-ffi-int
236 :lisp-stat-math
237 :lisp-stat-types
238 :lisp-stat-float
239 :lisp-stat-compound-data
240 :lisp-stat-linalg-data
241 :lisp-stat-matrix)
242 (:shadowing-import-from :lisp-stat-math
243 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
244 asin acos atan sinh cosh tanh asinh acosh atanh float random
245 truncate floor ceiling round minusp zerop plusp evenp oddp
246 < <= = /= >= > complex conjugate realpart imagpart phase
247 min max logand logior logxor lognot ffloor fceiling
248 ftruncate fround signum cis)
249 (:export chol-decomp lu-decomp lu-solve determinant inverse
250 sv-decomp qr-decomp rcondest make-rotation spline
251 kernel-dens kernel-smooth
252 fft make-sweep-matrix sweep-operator ax+y eigen
254 check-real ;; for optimize
256 covariance-matrix matrix print-matrix solve
257 backsolve eigenvalues eigenvectors accumulate cumsum combine
258 lowess))
261 (defpackage :lisp-stat-config
262 (:use :common-lisp)
263 (:export *default-path*
264 *lsos-files* *basic-files* *ls-files*
265 *lispstat-data-dir* *lispstat-examples-dir*))
268 (defpackage :lisp-stat-data
269 (:documentation "Data management, integration, I/O, and other data technologies.")
270 (:nicknames :ls-data)
271 (:use :common-lisp
272 :lisp-stat-object-system
273 :lisp-stat-config
274 :lisp-stat-types
275 :lisp-stat-compound-data)
276 (:shadowing-import-from :lisp-stat-object-system
277 slot-value call-method call-next-method)
278 (:export open-file-dialog read-data-file read-data-columns load-data
279 load-example *variables* *ask-on-redefine*
280 def variables savevar undef))
282 (defpackage :lisp-stat-descriptive-statistics
283 (:use :common-lisp
284 :lisp-stat-data
285 :lisp-stat-math
286 :lisp-stat-compound-data
287 :lisp-stat-matrix
288 :lisp-stat-linalg-data
289 :lisp-stat-linalg
290 :lisp-stat-basics)
291 (:shadowing-import-from :lisp-stat-math ;; life is a vector!
292 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
293 asin acos atan sinh cosh tanh asinh acosh atanh float random
294 truncate floor ceiling round minusp zerop plusp evenp oddp
295 < <= = /= >= > ;; complex
296 conjugate realpart imagpart phase
297 min max logand logior logxor lognot ffloor fceiling
298 ftruncate fround signum cis)
299 (:export standard-deviation quantile median interquartile-range
300 fivnum sample))
303 (defpackage :lisp-stat-regression-linear
304 (:use :common-lisp
305 :lisp-stat-object-system
306 :lisp-stat-basics
307 :lisp-stat-compound-data
308 :lisp-stat-math
309 :lisp-stat-matrix
310 :lisp-stat-linalg
311 :lisp-stat-descriptive-statistics)
312 (:shadowing-import-from :lisp-stat-object-system
313 slot-value call-method call-next-method)
314 (:shadowing-import-from :lisp-stat-math
315 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
316 asin acos atan sinh cosh tanh asinh acosh atanh float random
317 truncate floor ceiling round minusp zerop plusp evenp oddp
318 < <= = /= >= > ;; complex
319 conjugate realpart imagpart phase
320 min max logand logior logxor lognot ffloor fceiling
321 ftruncate fround signum cis)
322 (:export regression-model regression-model-proto x y intercept sweep-matrix
323 basis weights included total-sum-of-squares residual-sum-of-squares
324 predictor-names response-name case-labels))
327 (defpackage :lisp-stat
328 (:documentation "Experimentation package for LispStat. Serious
329 work should be packaged up elsewhere for reproducibility. By this
330 I mean, creating a data/analytics/analysis package with the
331 minimal set of objects required.")
332 (:use :common-lisp
333 :lisp-stat-object-system
334 :lisp-stat-compound-data
335 :lisp-stat-probability
336 :lisp-stat-types
337 :lisp-stat-float
338 :lisp-stat-basics
339 :lisp-stat-data
340 :lisp-stat-math
341 :lisp-stat-matrix
342 :lisp-stat-linalg
343 :lisp-stat-descriptive-statistics
344 :lisp-stat-regression-linear)
345 (:shadowing-import-from :lisp-stat-object-system
346 slot-value call-method call-next-method)
347 (:shadowing-import-from :lisp-stat-math
348 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
349 asin acos atan sinh cosh tanh asinh acosh atanh float random
350 truncate floor ceiling round minusp zerop plusp evenp oddp
351 < <= = /= >= > ;;complex
352 conjugate realpart imagpart phase
353 min max logand logior logxor lognot ffloor fceiling
354 ftruncate fround signum cis)
355 (:export
356 ;; lsobjects :
357 defproto defproto2
358 defmeth send
360 ;; lstypes :
361 fixnump check-nonneg-fixnum check-one-fixnum
362 check-one-real check-one-number
364 ;; lsmacros:
366 ;; lsfloat :
367 machine-epsilon
369 ;; compound :
370 compound-data-p *compound-data-proto* compound-object-p
371 compound-data-seq compound-data-length
372 element-list element-seq
373 sort-data order rank
374 recursive-map-elements map-elements
375 repeat
376 check-sequence
377 get-next-element make-next-element set-next-element
378 sequencep 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
392 ;; matrices.lisp
393 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
394 column-list inner-product outer-product cross-product transpose
395 bind-columns bind-rows
397 ;; linalg.lisp
398 chol-decomp lu-decomp lu-solve determinant inverse
399 sv-decomp qr-decomp rcondest make-rotation spline
400 kernel-dens kernel-smooth
401 fft make-sweep-matrix sweep-operator ax+y eigen
402 check-real
403 covariance-matrix matrix print-matrix solve
404 backsolve eigenvalues eigenvectors accumulate cumsum combine
405 lowess
407 ;; in linalg.lisp, possibly not supported by matlisp
408 spline kernel-dens kernel-smooth
410 ;; optimize.lsp
411 newtonmax nelmeadmax
413 ;; lispstat-macros
414 make-rv-function make-rv-function-1
416 ;; data.lisp
417 open-file-dialog read-data-file read-data-columns load-data
418 load-example *variables* *ask-on-redefine*
419 def variables savevar undef
421 ;; statistics.lsp
422 standard-deviation quantile median interquartile-range
423 fivnum sample
425 ;; dists
426 log-gamma set-seed
427 uniform-rand normal-cdf normal-quant normal-dens
428 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
429 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
430 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
431 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
432 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
433 binomial-cdf binomial-quant binomial-pmf binomial-rand
435 ;;; Here is where we have a problem -- lispstat core should be core
436 ;;; data management and config problems, with packages providing
437 ;;; specialized extensions to LispStat, i.e. regression, nonlin
438 ;;; regression, bayesian regression via laplace approximation, etc.
440 ;;; The following could be considered "recommended packages", similar
441 ;;; to the idea of the recommended packages in R.
443 ;; regression.lsp
444 regression-model regression-model-proto x y intercept sweep-matrix
445 basis weights included total-sum-of-squares residual-sum-of-squares
446 predictor-names response-name case-labels
448 ;; nonlin.lsp
449 nreg-model nreg-model-proto mean-function theta-hat epsilon
450 count-limit verbose
452 ;; bayes.lsp
453 bayes-model bayes-model-proto bayes-internals))
456 (defpackage :lisp-stat-data-examples
457 (:documentation "Example data used for unittests and illustrations,")
458 (:use :common-lisp
459 :lisp-stat)
460 (:shadowing-import-from :lisp-stat
461 slot-value call-method call-next-method
463 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
464 asin acos atan sinh cosh tanh asinh acosh atanh float random
465 truncate floor ceiling round minusp zerop plusp evenp oddp
466 < <= = /= >= > > ;; complex
467 conjugate realpart imagpart phase
468 min max logand logior logxor lognot ffloor fceiling
469 ftruncate fround signum cis
471 <= float imagpart)
472 (:export iron aluminum absorbtion
473 diabetes dlabs))
476 (defpackage :lisp-stat-user
477 (:documentation "Experimentation package for LispStat.
478 Serious work should be placed in a similar package elsewhere for
479 reproducibility. But this should hint as to what needs to be
480 done for a user- or analysis-package.")
481 (:nicknames :ls-user)
482 (:use :common-lisp
483 :lisp-stat
484 :lisp-stat-data-examples) ;; this last is to have 'things to play with'
485 (:shadowing-import-from :lisp-stat
486 slot-value call-method call-next-method
488 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
489 asin acos atan sinh cosh tanh asinh acosh atanh float random
490 truncate floor ceiling round minusp zerop plusp evenp oddp
491 < <= = /= >= > > ;; complex
492 conjugate realpart imagpart phase
493 min max logand logior logxor lognot ffloor fceiling
494 ftruncate fround signum cis
496 <= float imagpart))
500 ;;;
502 (defpackage :lisp-stat-unittests
503 (:use :common-lisp :lift :lisp-stat)
504 (:shadowing-import-from :lisp-stat
505 slot-value call-method call-next-method ;; objects
506 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath
507 asin acos atan sinh cosh tanh asinh acosh atanh float random
508 truncate floor ceiling round minusp zerop plusp evenp oddp
509 < <= = /= >= > ;; complex
510 conjugate realpart imagpart phase
511 min max logand logior logxor lognot ffloor fceiling
512 ftruncate fround signum cis)
513 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard ; exec
514 almost= almost=lists numerical=)) ; compare
517 (defpackage :lisp-stat-data-clos-example
518 (:use :common-lisp
519 :lift :lisp-stat-unittests
520 :lisp-stat-data-clos))