3 ;;; Time-stamp: <2009-03-18 12:12:51 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
115 ;; generic container class for data -- if small enough
116 ;; could be value, otherwise might be reference.
119 get-variable-matrix get-variable-vector
123 (defpackage :lisp-stat-regression-linear-clos
126 :lisp-stat-data-clos
)
127 (:export regression-model
))
130 (defpackage :lisp-stat-visualize
133 :lisp-stat-data-clos
))
135 (defpackage :lisp-stat-visualize-plplot
150 (defpackage :lisp-stat-ffi-int
153 (:export ccl-store-integer ccl-store-double ccl-store-ptr
156 (defpackage :lisp-stat-probability
161 (:export log-gamma set-seed
163 normal-cdf normal-quant normal-dens normal-rand
165 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
166 gamma-cdf gamma-quant gamma-dens gamma-rand
167 chisq-cdf chisq-quant chisq-dens chisq-rand
168 beta-cdf beta-quant beta-dens beta-rand
169 t-cdf t-quant t-dens t-rand
170 f-cdf f-quant f-dens f-rand
171 poisson-cdf poisson-quant poisson-pmf poisson-rand
172 binomial-cdf binomial-quant binomial-pmf binomial-rand
))
175 #| removed
, replace by lisp-matrix
176 (defpackage :lisp-stat-matrix
179 :lisp-stat-compound-data
)
180 (:export matrixp
;; matrix -- conflicts!
181 num-rows num-cols matmult identity-matrix diagonal
182 row-list column-list inner-product outer-product
184 ;; transpose bind-columns bind-rows
185 array-data-vector vector-to-array
187 check-matrix check-square-matrix
189 copy-array copy-vector
193 #| replaced by lisp-matrix
194 (defpackage :lisp-stat-linalg-data
199 :lisp-stat-compound-data
201 (:export
;; more to add
202 +mode-in
+ +mode-re
+ +mode-cx
+ mode-of
204 la-data-mode la-allocate la-free
206 la-get-double la-put-double
209 la-matrix la-free-matrix la-matrix-to-data la-data-to-matrix
210 la-vector la-free-vector la-vector-to-data la-data-to-vector
))
213 (defpackage :lisp-stat-math
215 :lisp-stat-object-system
217 :lisp-stat-compound-data
219 (:shadowing-import-from
:lisp-stat-object-system
220 slot-value call-method call-next-method
)
221 (:shadow expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
222 asin acos atan sinh cosh tanh asinh acosh atanh float random
223 truncate floor ceiling round minusp zerop plusp evenp oddp
224 < <= = /= >= > ;; complex
225 conjugate realpart imagpart phase
226 min max logand logior logxor lognot ffloor fceiling
227 ftruncate fround signum cis
)
228 (:export ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
229 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
230 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
232 conjugate realpart imagpart phase min max
233 logand logior logxor lognot ffloor fceiling ftruncate fround
235 (:documentation
"Vectorization of numerical functions"))
238 #|
;; some of this goes back in, but not all of it?
239 (defpackage :lisp-stat-linalg
246 :lisp-stat-compound-data
)
247 (:shadowing-import-from
:lisp-stat-math
248 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
249 asin acos atan sinh cosh tanh asinh acosh atanh float random
250 truncate floor ceiling round minusp zerop plusp evenp oddp
251 < <= = /= >= > complex conjugate realpart imagpart phase
252 min max logand logior logxor lognot ffloor fceiling
253 ftruncate fround signum cis
)
254 (:export chol-decomp lu-decomp lu-solve determinant inverse
255 sv-decomp qr-decomp rcondest make-rotation spline
256 kernel-dens kernel-smooth
257 fft make-sweep-matrix sweep-operator ax
+y eigen
259 check-real
;; for optimize
261 covariance-matrix matrix print-matrix solve
262 backsolve eigenvalues eigenvectors accumulate cumsum combine
270 (defpackage :lisp-stat-data
271 (:documentation
"Data management, integration, I/O, and other data technologies.")
272 (:nicknames
:ls-data
)
274 :lisp-stat-object-system
277 :lisp-stat-compound-data
)
278 (:shadowing-import-from
:lisp-stat-object-system
279 slot-value call-method call-next-method
)
280 (:export open-file-dialog read-data-file read-data-columns load-data
281 load-example
*variables
* *ask-on-redefine
*
282 def variables savevar undef
))
284 (defpackage :lisp-stat-descriptive-statistics
288 :lisp-stat-compound-data
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
300 quantile median interquartile-range
304 (defpackage :lisp-stat-regression-linear
307 :lisp-stat-object-system
309 :lisp-stat-compound-data
310 :lisp-stat-descriptive-statistics
315 (:shadowing-import-from
:lisp-stat-object-system
316 slot-value call-method call-next-method
)
318 (:shadowing-import-from
:lisp-stat-math
319 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
320 asin acos atan sinh cosh tanh asinh acosh atanh float random
321 truncate floor ceiling round minusp zerop plusp evenp oddp
322 < <= = /= >= > ;; complex
323 conjugate realpart imagpart phase
324 min max logand logior logxor lognot ffloor fceiling
325 ftruncate fround signum cis
)
327 (:export regression-model regression-model-proto x y intercept
329 basis weights included
330 total-sum-of-squares residual-sum-of-squares
331 predictor-names response-name case-labels
332 ;; functions for helpers
335 (defpackage :lisp-stat
336 (:documentation
"Experimentation package for LispStat. Serious
337 work should be packaged up elsewhere for reproducibility. By this
338 I mean, creating a data/analytics/analysis package with the
339 minimal set of objects required.")
341 :lisp-stat-object-system
342 :lisp-stat-compound-data
343 :lisp-stat-probability
350 :lisp-matrix
;; conversion to a more robust linalg approach
351 :lisp-stat-descriptive-statistics
352 :lisp-stat-regression-linear
354 (:shadowing-import-from
:lisp-stat-object-system
355 slot-value call-method call-next-method
)
356 (:shadowing-import-from
:lisp-stat-math
357 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
358 asin acos atan sinh cosh tanh asinh acosh atanh float random
359 truncate floor ceiling round minusp zerop plusp evenp oddp
362 conjugate realpart imagpart phase
365 logand logior logxor lognot
366 ffloor fceiling ftruncate fround
374 fixnump check-nonneg-fixnum check-one-fixnum
375 check-one-real check-one-number
383 compound-data-p
*compound-data-proto
* compound-object-p
384 compound-data-seq compound-data-length
385 element-list element-seq
387 recursive-map-elements map-elements
390 get-next-element make-next-element set-next-element
398 ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
399 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
400 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
402 conjugate realpart imagpart phase min max
403 logand logior logxor lognot ffloor fceiling ftruncate fround
406 #|
;; The following need to be re-found in lisp-matrix...
409 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
410 column-list inner-product outer-product cross-product transpose
411 bind-columns bind-rows
414 chol-decomp lu-decomp lu-solve determinant inverse
415 sv-decomp qr-decomp rcondest make-rotation spline
416 kernel-dens kernel-smooth
417 fft make-sweep-matrix sweep-operator ax
+y eigen
419 covariance-matrix matrix print-matrix solve
420 backsolve eigenvalues eigenvectors accumulate cumsum combine
423 ;; in linalg.lisp, possibly not supported by matlisp
424 spline kernel-dens kernel-smooth
432 make-rv-function make-rv-function-1
435 open-file-dialog read-data-file read-data-columns load-data
436 load-example
*variables
* *ask-on-redefine
*
437 def variables savevar undef
445 ;; statistics.lsp (descriptions, should probably be moved
447 standard-deviation quantile median interquartile-range
450 ;; probability (dists.lisp)
452 uniform-rand normal-cdf normal-quant normal-dens
453 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
454 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
455 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
456 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
457 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
458 binomial-cdf binomial-quant binomial-pmf binomial-rand
460 ;; Here is where we have a problem -- lispstat core should be core
461 ;; data management and config problems, with packages providing
462 ;; specialized extensions to LispStat, i.e. regression, nonlin
463 ;; regression, bayesian regression via laplace approximation, etc.
465 ;; The following could be considered "recommended packages",
466 ;; similar to the idea of the recommended packages in R. Probably
467 ;; we want them to do the exporting within that package, therefore
468 ;; NOT being able to lock the "data-ish" package, but only the
469 ;; subpackages prior to export.
472 ;; -- linear regressin models.
473 regression-model regression-model-proto x y intercept sweep-matrix
474 basis weights included total-sum-of-squares residual-sum-of-squares
475 predictor-names response-name case-labels
479 ;; -- nonlinear regression models
480 nreg-model nreg-model-proto mean-function theta-hat epsilon
482 ;; we might need something like xtxinv here? But should be
483 ;; encapsulated, so we use the one in regression.lisp
486 bayes-model bayes-model-proto bayes-internals
499 ;;;; PACKAGES FOR USEABILITY
501 (defpackage :lisp-stat-data-examples
502 (:documentation
"Example data for unittests, examples, illustrations,")
505 (:shadowing-import-from
:lisp-stat
506 slot-value call-method call-next-method
508 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
509 asin acos atan sinh cosh tanh asinh acosh atanh float random
510 truncate floor ceiling round minusp zerop plusp evenp oddp
511 < <= = /= >= > > ;; complex
512 conjugate realpart imagpart phase
513 min max logand logior logxor lognot ffloor fceiling
514 ftruncate fround signum cis
517 (:export iron aluminum absorbtion
521 (defpackage :lisp-stat-user
522 (:documentation
"Experimentation package for LispStat.
523 Serious work should be placed in a similar package elsewhere for
524 reproducibility. But this should hint as to what needs to be
525 done for a user- or analysis-package.")
526 (:nicknames
:ls-user
)
530 :lisp-stat-data-examples
) ;; this last is to have 'things to play with'
531 (:shadowing-import-from
:lisp-stat
532 slot-value call-method call-next-method
534 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
535 asin acos atan sinh cosh tanh asinh acosh atanh float random
536 truncate floor ceiling round minusp zerop plusp evenp oddp
537 < <= = /= >= > > ;; complex
538 conjugate realpart imagpart phase
539 min max logand logior logxor lognot ffloor fceiling
540 ftruncate fround signum cis
544 (defpackage :lisp-stat-unittests
545 (:use
:common-lisp
:lift
:lisp-stat
:lisp-stat-data-examples
)
546 (:shadowing-import-from
:lisp-stat
547 slot-value call-method call-next-method
;; objects
548 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
;; lsmath
549 asin acos atan sinh cosh tanh asinh acosh atanh float random
550 truncate floor ceiling round minusp zerop plusp evenp oddp
551 < <= = /= >= > ;; complex
552 conjugate realpart imagpart phase
553 min max logand logior logxor lognot ffloor fceiling
554 ftruncate fround signum cis
)
555 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard
; exec
556 almost
= almost
=lists numerical
=)) ; compare
558 (defpackage :lisp-stat-data-clos-example
560 :lift
:lisp-stat-unittests
561 :lisp-stat-data-examples
562 :lisp-stat-data-clos
)
563 (:export absorbtion aluminum iron
))
566 (defpackage :lisp-stat-optimize
571 :lisp-stat-object-system
573 :lisp-stat-compound-data
579 :lisp-stat-linalg-data
583 (:shadowing-import-from
:lisp-stat-object-system
584 slot-value call-method call-next-method
)
585 (:shadowing-import-from
:lisp-stat-math
586 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
587 asin acos atan sinh cosh tanh asinh acosh atanh float random
588 truncate floor ceiling round minusp zerop plusp evenp oddp
589 < <= = /= >= > complex conjugate realpart imagpart phase
590 min max logand logior logxor lognot ffloor fceiling
591 ftruncate fround signum cis
)
597 newtonmax nelmeadmax
))