3 ;;; Time-stamp: <2009-03-16 21:56:47 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
))
133 (defpackage :lisp-stat-ffi-int
136 (:export ccl-store-integer ccl-store-double ccl-store-ptr
139 (defpackage :lisp-stat-probability
144 (:export log-gamma set-seed
146 normal-cdf normal-quant normal-dens normal-rand
148 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
149 gamma-cdf gamma-quant gamma-dens gamma-rand
150 chisq-cdf chisq-quant chisq-dens chisq-rand
151 beta-cdf beta-quant beta-dens beta-rand
152 t-cdf t-quant t-dens t-rand
153 f-cdf f-quant f-dens f-rand
154 poisson-cdf poisson-quant poisson-pmf poisson-rand
155 binomial-cdf binomial-quant binomial-pmf binomial-rand
))
158 #| removed
, replace by lisp-matrix
159 (defpackage :lisp-stat-matrix
162 :lisp-stat-compound-data
)
163 (:export matrixp
;; matrix -- conflicts!
164 num-rows num-cols matmult identity-matrix diagonal
165 row-list column-list inner-product outer-product
167 ;; transpose bind-columns bind-rows
168 array-data-vector vector-to-array
170 check-matrix check-square-matrix
172 copy-array copy-vector
176 #| replaced by lisp-matrix
177 (defpackage :lisp-stat-linalg-data
182 :lisp-stat-compound-data
184 (:export
;; more to add
185 +mode-in
+ +mode-re
+ +mode-cx
+ mode-of
187 la-data-mode la-allocate la-free
189 la-get-double la-put-double
192 la-matrix la-free-matrix la-matrix-to-data la-data-to-matrix
193 la-vector la-free-vector la-vector-to-data la-data-to-vector
))
196 (defpackage :lisp-stat-math
198 :lisp-stat-object-system
200 :lisp-stat-compound-data
202 (:shadowing-import-from
:lisp-stat-object-system
203 slot-value call-method call-next-method
)
204 (:shadow expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
205 asin acos atan sinh cosh tanh asinh acosh atanh float random
206 truncate floor ceiling round minusp zerop plusp evenp oddp
207 < <= = /= >= > ;; complex
208 conjugate realpart imagpart phase
209 min max logand logior logxor lognot ffloor fceiling
210 ftruncate fround signum cis
)
211 (:export ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
212 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
213 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
215 conjugate realpart imagpart phase min max
216 logand logior logxor lognot ffloor fceiling ftruncate fround
218 (:documentation
"Vectorization of numerical functions"))
221 #|
;; some of this goes back in, but not all of it?
222 (defpackage :lisp-stat-linalg
229 :lisp-stat-compound-data
)
230 (:shadowing-import-from
:lisp-stat-math
231 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
232 asin acos atan sinh cosh tanh asinh acosh atanh float random
233 truncate floor ceiling round minusp zerop plusp evenp oddp
234 < <= = /= >= > complex conjugate realpart imagpart phase
235 min max logand logior logxor lognot ffloor fceiling
236 ftruncate fround signum cis
)
237 (:export chol-decomp lu-decomp lu-solve determinant inverse
238 sv-decomp qr-decomp rcondest make-rotation spline
239 kernel-dens kernel-smooth
240 fft make-sweep-matrix sweep-operator ax
+y eigen
242 check-real
;; for optimize
244 covariance-matrix matrix print-matrix solve
245 backsolve eigenvalues eigenvectors accumulate cumsum combine
253 (defpackage :lisp-stat-data
254 (:documentation
"Data management, integration, I/O, and other data technologies.")
255 (:nicknames
:ls-data
)
257 :lisp-stat-object-system
260 :lisp-stat-compound-data
)
261 (:shadowing-import-from
:lisp-stat-object-system
262 slot-value call-method call-next-method
)
263 (:export open-file-dialog read-data-file read-data-columns load-data
264 load-example
*variables
* *ask-on-redefine
*
265 def variables savevar undef
))
267 (defpackage :lisp-stat-descriptive-statistics
271 :lisp-stat-compound-data
274 (:shadowing-import-from
:lisp-stat-math
;; life is a vector!
275 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
276 asin acos atan sinh cosh tanh asinh acosh atanh float random
277 truncate floor ceiling round minusp zerop plusp evenp oddp
278 < <= = /= >= > ;; complex
279 conjugate realpart imagpart phase
280 min max logand logior logxor lognot ffloor fceiling
281 ftruncate fround signum cis
)
282 (:export standard-deviation
283 quantile median interquartile-range
287 (defpackage :lisp-stat-regression-linear
290 :lisp-stat-object-system
292 :lisp-stat-compound-data
293 :lisp-stat-descriptive-statistics
298 (:shadowing-import-from
:lisp-stat-object-system
299 slot-value call-method call-next-method
)
301 (:shadowing-import-from
:lisp-stat-math
302 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
303 asin acos atan sinh cosh tanh asinh acosh atanh float random
304 truncate floor ceiling round minusp zerop plusp evenp oddp
305 < <= = /= >= > ;; complex
306 conjugate realpart imagpart phase
307 min max logand logior logxor lognot ffloor fceiling
308 ftruncate fround signum cis
)
310 (:export regression-model regression-model-proto x y intercept
312 basis weights included
313 total-sum-of-squares residual-sum-of-squares
314 predictor-names response-name case-labels
315 ;; functions for helpers
318 (defpackage :lisp-stat
319 (:documentation
"Experimentation package for LispStat. Serious
320 work should be packaged up elsewhere for reproducibility. By this
321 I mean, creating a data/analytics/analysis package with the
322 minimal set of objects required.")
324 :lisp-stat-object-system
325 :lisp-stat-compound-data
326 :lisp-stat-probability
333 :lisp-matrix
;; conversion to a more robust linalg approach
334 :lisp-stat-descriptive-statistics
335 :lisp-stat-regression-linear
337 (:shadowing-import-from
:lisp-stat-object-system
338 slot-value call-method call-next-method
)
339 (:shadowing-import-from
:lisp-stat-math
340 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
341 asin acos atan sinh cosh tanh asinh acosh atanh float random
342 truncate floor ceiling round minusp zerop plusp evenp oddp
345 conjugate realpart imagpart phase
348 logand logior logxor lognot
349 ffloor fceiling ftruncate fround
357 fixnump check-nonneg-fixnum check-one-fixnum
358 check-one-real check-one-number
366 compound-data-p
*compound-data-proto
* compound-object-p
367 compound-data-seq compound-data-length
368 element-list element-seq
370 recursive-map-elements map-elements
373 get-next-element make-next-element set-next-element
381 ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
382 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
383 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
385 conjugate realpart imagpart phase min max
386 logand logior logxor lognot ffloor fceiling ftruncate fround
389 #|
;; The following need to be re-found in lisp-matrix...
392 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
393 column-list inner-product outer-product cross-product transpose
394 bind-columns bind-rows
397 chol-decomp lu-decomp lu-solve determinant inverse
398 sv-decomp qr-decomp rcondest make-rotation spline
399 kernel-dens kernel-smooth
400 fft make-sweep-matrix sweep-operator ax
+y eigen
402 covariance-matrix matrix print-matrix solve
403 backsolve eigenvalues eigenvectors accumulate cumsum combine
406 ;; in linalg.lisp, possibly not supported by matlisp
407 spline kernel-dens kernel-smooth
415 make-rv-function make-rv-function-1
418 open-file-dialog read-data-file read-data-columns load-data
419 load-example
*variables
* *ask-on-redefine
*
420 def variables savevar undef
428 ;; statistics.lsp (descriptions, should probably be moved
430 standard-deviation quantile median interquartile-range
433 ;; probability (dists.lisp)
435 uniform-rand normal-cdf normal-quant normal-dens
436 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
437 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
438 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
439 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
440 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
441 binomial-cdf binomial-quant binomial-pmf binomial-rand
443 ;; Here is where we have a problem -- lispstat core should be core
444 ;; data management and config problems, with packages providing
445 ;; specialized extensions to LispStat, i.e. regression, nonlin
446 ;; regression, bayesian regression via laplace approximation, etc.
448 ;; The following could be considered "recommended packages",
449 ;; similar to the idea of the recommended packages in R. Probably
450 ;; we want them to do the exporting within that package, therefore
451 ;; NOT being able to lock the "data-ish" package, but only the
452 ;; subpackages prior to export.
455 ;; -- linear regressin models.
456 regression-model regression-model-proto x y intercept sweep-matrix
457 basis weights included total-sum-of-squares residual-sum-of-squares
458 predictor-names response-name case-labels
462 ;; -- nonlinear regression models
463 nreg-model nreg-model-proto mean-function theta-hat epsilon
465 ;; we might need something like xtxinv here? But should be
466 ;; encapsulated, so we use the one in regression.lisp
469 bayes-model bayes-model-proto bayes-internals
))
472 ;;;; PACKAGES FOR USEABILITY
474 (defpackage :lisp-stat-data-examples
475 (:documentation
"Example data for unittests, examples, illustrations,")
478 (:shadowing-import-from
:lisp-stat
479 slot-value call-method call-next-method
481 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
482 asin acos atan sinh cosh tanh asinh acosh atanh float random
483 truncate floor ceiling round minusp zerop plusp evenp oddp
484 < <= = /= >= > > ;; complex
485 conjugate realpart imagpart phase
486 min max logand logior logxor lognot ffloor fceiling
487 ftruncate fround signum cis
490 (:export iron aluminum absorbtion
494 (defpackage :lisp-stat-user
495 (:documentation
"Experimentation package for LispStat.
496 Serious work should be placed in a similar package elsewhere for
497 reproducibility. But this should hint as to what needs to be
498 done for a user- or analysis-package.")
499 (:nicknames
:ls-user
)
503 :lisp-stat-data-examples
) ;; this last is to have 'things to play with'
504 (:shadowing-import-from
:lisp-stat
505 slot-value call-method call-next-method
507 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
508 asin acos atan sinh cosh tanh asinh acosh atanh float random
509 truncate floor ceiling round minusp zerop plusp evenp oddp
510 < <= = /= >= > > ;; complex
511 conjugate realpart imagpart phase
512 min max logand logior logxor lognot ffloor fceiling
513 ftruncate fround signum cis
517 (defpackage :lisp-stat-unittests
518 (:use
:common-lisp
:lift
:lisp-stat
:lisp-stat-data-examples
)
519 (:shadowing-import-from
:lisp-stat
520 slot-value call-method call-next-method
;; objects
521 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
;; lsmath
522 asin acos atan sinh cosh tanh asinh acosh atanh float random
523 truncate floor ceiling round minusp zerop plusp evenp oddp
524 < <= = /= >= > ;; complex
525 conjugate realpart imagpart phase
526 min max logand logior logxor lognot ffloor fceiling
527 ftruncate fround signum cis
)
528 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard
; exec
529 almost
= almost
=lists numerical
=)) ; compare
531 (defpackage :lisp-stat-data-clos-example
533 :lift
:lisp-stat-unittests
534 :lisp-stat-data-examples
535 :lisp-stat-data-clos
)
536 (:export absorbtion aluminum iron
))
539 (defpackage :lisp-stat-optimize
544 :lisp-stat-object-system
546 :lisp-stat-compound-data
552 :lisp-stat-linalg-data
556 (:shadowing-import-from
:lisp-stat-object-system
557 slot-value call-method call-next-method
)
558 (:shadowing-import-from
:lisp-stat-math
559 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
560 asin acos atan sinh cosh tanh asinh acosh atanh float random
561 truncate floor ceiling round minusp zerop plusp evenp oddp
562 < <= = /= >= > complex conjugate realpart imagpart phase
563 min max logand logior logxor lognot ffloor fceiling
564 ftruncate fround signum cis
)
570 newtonmax nelmeadmax
))