3 ;;; Time-stamp: <2009-03-11 05:53:30 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
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
22 (defpackage :lisp-stat-object-system
23 (:nicknames
:ls-objects
:lsos
)
25 (:shadow
:call-method
:call-next-method
:slot-value
)
26 (:export ls-object objectp
*object
* kind-of-p make-object
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
37 check-nonneg-fixnum check-one-nonneg-fixnum
38 check-one-fixnum check-one-real check-one-number
))
40 (defpackage :lisp-stat-float
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
55 :lisp-stat-object-system
57 (:shadowing-import-from
:lisp-stat-object-system
59 call-next-method call-method
)
60 (:export compound-data-p
*compound-data-proto
*
62 compound-data-seq compound-data-length
63 element-list element-seq
65 recursive-map-elements map-elements repeat
67 get-next-element make-next-element set-next-element
70 select split-list which
74 (defpackage :lisp-stat-macros
76 :lisp-stat-compound-data
)
77 (:export make-rv-function make-rv-function-1
))
79 (defpackage :lisp-stat-basics
81 :lisp-stat-object-system
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
91 (defpackage :lisp-stat-float
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
106 :lisp-stat-compound-data
)
107 (:export make-rv-function make-rv-function-1
))
109 ;;; NEW CLOS STRUCTURE
111 (defpackage :lisp-stat-data-clos
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.
120 (defpackage :lisp-stat-regression-linear-clos
123 :lisp-stat-data-clos
)
124 (:export regression-model
))
130 (defpackage :lisp-stat-ffi-int
133 (:export ccl-store-integer ccl-store-double ccl-store-ptr
136 (defpackage :lisp-stat-probability
141 (:export log-gamma set-seed
143 normal-cdf normal-quant normal-dens normal-rand
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
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
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
179 :lisp-stat-compound-data
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
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
195 :lisp-stat-object-system
197 :lisp-stat-compound-data
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
< <= =
212 conjugate realpart imagpart phase min max
213 logand logior logxor lognot ffloor fceiling ftruncate fround
215 (:documentation
"Vectorization of numerical functions"))
218 #|
;; some of this goes back in, but not all of it?
219 (defpackage :lisp-stat-linalg
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
250 (defpackage :lisp-stat-data
251 (:documentation
"Data management, integration, I/O, and other data technologies.")
252 (:nicknames
:ls-data
)
254 :lisp-stat-object-system
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
268 :lisp-stat-compound-data
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
280 quantile median interquartile-range
284 (defpackage :lisp-stat-regression-linear
287 :lisp-stat-object-system
289 :lisp-stat-compound-data
290 :lisp-stat-descriptive-statistics
295 (:shadowing-import-from
:lisp-stat-object-system
296 slot-value call-method call-next-method
)
298 (:shadowing-import-from
:lisp-stat-math
299 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
300 asin acos atan sinh cosh tanh asinh acosh atanh float random
301 truncate floor ceiling round minusp zerop plusp evenp oddp
302 < <= = /= >= > ;; complex
303 conjugate realpart imagpart phase
304 min max logand logior logxor lognot ffloor fceiling
305 ftruncate fround signum cis
)
307 (:export regression-model regression-model-proto x y intercept
309 basis weights included
310 total-sum-of-squares residual-sum-of-squares
311 predictor-names response-name case-labels
312 ;; functions for helpers
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.")
321 :lisp-stat-object-system
322 :lisp-stat-compound-data
323 :lisp-stat-probability
329 :lisp-matrix
;; conversion to a more robust linalg approach
330 :lisp-stat-descriptive-statistics
331 :lisp-stat-regression-linear
333 (:shadowing-import-from
:lisp-stat-object-system
334 slot-value call-method call-next-method
)
335 (:shadowing-import-from
:lisp-stat-math
336 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
337 asin acos atan sinh cosh tanh asinh acosh atanh float random
338 truncate floor ceiling round minusp zerop plusp evenp oddp
341 conjugate realpart imagpart phase
344 logand logior logxor lognot
345 ffloor fceiling ftruncate fround
353 fixnump check-nonneg-fixnum check-one-fixnum
354 check-one-real check-one-number
362 compound-data-p
*compound-data-proto
* compound-object-p
363 compound-data-seq compound-data-length
364 element-list element-seq
366 recursive-map-elements map-elements
369 get-next-element make-next-element set-next-element
377 ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
378 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
379 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
381 conjugate realpart imagpart phase min max
382 logand logior logxor lognot ffloor fceiling ftruncate fround
385 #|
;; The following need to be re-found in lisp-matrix...
388 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
389 column-list inner-product outer-product cross-product transpose
390 bind-columns bind-rows
393 chol-decomp lu-decomp lu-solve determinant inverse
394 sv-decomp qr-decomp rcondest make-rotation spline
395 kernel-dens kernel-smooth
396 fft make-sweep-matrix sweep-operator ax
+y eigen
398 covariance-matrix matrix print-matrix solve
399 backsolve eigenvalues eigenvectors accumulate cumsum combine
402 ;; in linalg.lisp, possibly not supported by matlisp
403 spline kernel-dens kernel-smooth
411 make-rv-function make-rv-function-1
414 open-file-dialog read-data-file read-data-columns load-data
415 load-example
*variables
* *ask-on-redefine
*
416 def variables savevar undef
418 ;; statistics.lsp (descriptions, should probably be moved
420 standard-deviation quantile median interquartile-range
423 ;; probability (dists.lisp)
425 uniform-rand normal-cdf normal-quant normal-dens
426 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
427 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
428 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
429 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
430 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
431 binomial-cdf binomial-quant binomial-pmf binomial-rand
433 ;; Here is where we have a problem -- lispstat core should be core
434 ;; data management and config problems, with packages providing
435 ;; specialized extensions to LispStat, i.e. regression, nonlin
436 ;; regression, bayesian regression via laplace approximation, etc.
438 ;; The following could be considered "recommended packages",
439 ;; similar to the idea of the recommended packages in R. Probably
440 ;; we want them to do the exporting within that package, therefore
441 ;; NOT being able to lock the "data-ish" package, but only the
442 ;; subpackages prior to export.
445 ;; -- linear regressin models.
446 regression-model regression-model-proto x y intercept sweep-matrix
447 basis weights included total-sum-of-squares residual-sum-of-squares
448 predictor-names response-name case-labels
452 ;; -- nonlinear regression models
453 nreg-model nreg-model-proto mean-function theta-hat epsilon
455 ;; we might need something like xtxinv here? But should be
456 ;; encapsulated, so we use the one in regression.lisp
459 bayes-model bayes-model-proto bayes-internals
))
462 ;;;; PACKAGES FOR USEABILITY
464 (defpackage :lisp-stat-data-examples
465 (:documentation
"Example data for unittests, examples, illustrations,")
468 (:shadowing-import-from
:lisp-stat
469 slot-value call-method call-next-method
471 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
472 asin acos atan sinh cosh tanh asinh acosh atanh float random
473 truncate floor ceiling round minusp zerop plusp evenp oddp
474 < <= = /= >= > > ;; complex
475 conjugate realpart imagpart phase
476 min max logand logior logxor lognot ffloor fceiling
477 ftruncate fround signum cis
480 (:export iron aluminum absorbtion
484 (defpackage :lisp-stat-user
485 (:documentation
"Experimentation package for LispStat.
486 Serious work should be placed in a similar package elsewhere for
487 reproducibility. But this should hint as to what needs to be
488 done for a user- or analysis-package.")
489 (:nicknames
:ls-user
)
493 :lisp-stat-data-examples
) ;; this last is to have 'things to play with'
494 (:shadowing-import-from
:lisp-stat
495 slot-value call-method call-next-method
497 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
498 asin acos atan sinh cosh tanh asinh acosh atanh float random
499 truncate floor ceiling round minusp zerop plusp evenp oddp
500 < <= = /= >= > > ;; complex
501 conjugate realpart imagpart phase
502 min max logand logior logxor lognot ffloor fceiling
503 ftruncate fround signum cis
507 (defpackage :lisp-stat-unittests
508 (:use
:common-lisp
:lift
:lisp-stat
:lisp-stat-data-examples
)
509 (:shadowing-import-from
:lisp-stat
510 slot-value call-method call-next-method
;; objects
511 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
;; lsmath
512 asin acos atan sinh cosh tanh asinh acosh atanh float random
513 truncate floor ceiling round minusp zerop plusp evenp oddp
514 < <= = /= >= > ;; complex
515 conjugate realpart imagpart phase
516 min max logand logior logxor lognot ffloor fceiling
517 ftruncate fround signum cis
)
518 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard
; exec
519 almost
= almost
=lists numerical
=)) ; compare
521 (defpackage :lisp-stat-data-clos-example
523 :lift
:lisp-stat-unittests
524 :lisp-stat-data-examples
525 :lisp-stat-data-clos
)
526 (:export absorbtion aluminum iron
))
529 (defpackage :lisp-stat-optimize
534 :lisp-stat-object-system
536 :lisp-stat-compound-data
542 :lisp-stat-linalg-data
546 (:shadowing-import-from
:lisp-stat-object-system
547 slot-value call-method call-next-method
)
548 (:shadowing-import-from
:lisp-stat-math
549 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
550 asin acos atan sinh cosh tanh asinh acosh atanh float random
551 truncate floor ceiling round minusp zerop plusp evenp oddp
552 < <= = /= >= > complex conjugate realpart imagpart phase
553 min max logand logior logxor lognot ffloor fceiling
554 ftruncate fround signum cis
)
560 newtonmax nelmeadmax
))