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
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
24 (defpackage :lisp-stat-object-system
25 (:nicknames
:ls-objects
:lsos
)
27 (:shadow
:call-method
:call-next-method
:slot-value
)
28 (:export ls-object objectp
*object
* kind-of-p make-object
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
43 check-nonneg-fixnum check-one-nonneg-fixnum
44 check-one-fixnum check-one-real check-one-number
))
51 (defpackage :lisp-stat-float
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
67 :lisp-stat-object-system
69 (:shadowing-import-from
:lisp-stat-object-system
71 call-next-method call-method
)
72 (:export compound-data-p
*compound-data-proto
*
74 compound-data-seq compound-data-length
75 element-list element-seq
77 recursive-map-elements map-elements repeat
79 get-next-element make-next-element set-next-element
80 sequencep iseq ordered-nneg-seq
81 select split-list which
85 (defpackage :lisp-stat-macros
87 :lisp-stat-compound-data
)
88 (:export make-rv-function make-rv-function-1
))
90 (defpackage :lisp-stat-basics
92 :lisp-stat-object-system
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
107 (defpackage :lisp-stat-float
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
))
122 (defpackage :lisp-stat-macros
124 :lisp-stat-compound-data
)
125 (:export make-rv-function make-rv-function-1
))
127 ;;; NEW CLOS STRUCTURE
129 (defpackage :lisp-stat-data-clos
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.
137 (defpackage :lisp-stat-regression-linear-clos
140 :lisp-stat-data-clos
)
141 (:export regression-model
))
147 (defpackage :lisp-stat-ffi-int
150 (:export ccl-store-integer ccl-store-double ccl-store-ptr
153 (defpackage :lisp-stat-probability
158 (:export log-gamma set-seed
160 normal-cdf normal-quant normal-dens normal-rand
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
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
193 :lisp-stat-compound-data
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
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
209 :lisp-stat-object-system
211 :lisp-stat-compound-data
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
< <= =
226 conjugate realpart imagpart phase min max
227 logand logior logxor lognot ffloor fceiling ftruncate fround
229 (:documentation
"Vectorization of numerical functions"))
232 (defpackage :lisp-stat-linalg
239 :lisp-stat-compound-data
240 :lisp-stat-linalg-data
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
261 (defpackage :lisp-stat-config
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
)
272 :lisp-stat-object-system
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
286 :lisp-stat-compound-data
288 :lisp-stat-linalg-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 quantile median interquartile-range
303 (defpackage :lisp-stat-regression-linear
305 :lisp-stat-object-system
307 :lisp-stat-compound-data
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.")
333 :lisp-stat-object-system
334 :lisp-stat-compound-data
335 :lisp-stat-probability
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
)
361 fixnump check-nonneg-fixnum check-one-fixnum
362 check-one-real check-one-number
370 compound-data-p
*compound-data-proto
* compound-object-p
371 compound-data-seq compound-data-length
372 element-list element-seq
374 recursive-map-elements map-elements
377 get-next-element make-next-element set-next-element
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
< <= =
388 conjugate realpart imagpart phase min max
389 logand logior logxor lognot ffloor fceiling ftruncate fround
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
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
403 covariance-matrix matrix print-matrix solve
404 backsolve eigenvalues eigenvectors accumulate cumsum combine
407 ;; in linalg.lisp, possibly not supported by matlisp
408 spline kernel-dens kernel-smooth
414 make-rv-function make-rv-function-1
417 open-file-dialog read-data-file read-data-columns load-data
418 load-example
*variables
* *ask-on-redefine
*
419 def variables savevar undef
422 standard-deviation quantile median interquartile-range
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.
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
449 nreg-model nreg-model-proto mean-function theta-hat epsilon
453 bayes-model bayes-model-proto bayes-internals
))
456 (defpackage :lisp-stat-data-examples
457 (:documentation
"Example data used for unittests and illustrations,")
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
472 (:export iron aluminum absorbtion
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
)
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
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
519 :lift
:lisp-stat-unittests
520 :lisp-stat-data-clos
))