3 ;;; Time-stamp: <2009-04-13 12:03:08 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
23 (defpackage :lisp-stat-object-system
24 (:nicknames
:ls-objects
:lsos
)
26 (:shadow
:call-method
:call-next-method
)
27 (:export ls-object objectp
*object
* kind-of-p make-object
29 *set-slot-hook
* proto-slot-value self
30 send call-next-method call-method
31 defmeth defproto instance-slots proto-name
))
33 (defpackage :lisp-stat-types
34 (:documentation
"Provides some typeing for LispStat, but is clearly
38 check-nonneg-fixnum check-one-nonneg-fixnum
39 check-one-fixnum check-one-real check-one-number
))
41 (defpackage :lisp-stat-float
43 (:export
+stat-float-typing
+ +stat-cfloat-typing
+ +stat-float-template
+
44 machine-epsilon base-float makedouble
46 make-base-trans-fun-2 make-base-trans-fun
48 base-log base-exp base-expt base-sqrt base-sin base-cos
49 base-tan base-asin base-acos base-atan base-sinh
50 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
51 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
52 BASE-FROUND BASE-SIGNUM BASE-CIS
))
54 (defpackage :lisp-stat-compound-data
56 :lisp-stat-object-system
58 (: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 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
113 (defpackage :lisp-stat-dataframe
117 ;; generic container class for data -- if small enough
118 ;; could be value, otherwise might be reference.
124 varlabels caselabels nrows ncols
125 dataframe-dimension dataframe-dimensons
126 dfref dfref-case dfref-var
127 consistent-dataframe-p
130 list-of-columns
;; list-of-variables
131 list-of-rows
;; list-of-observations
135 (defpackage :cls-data-listoflist
137 :lisp-stat-dataframe
) ; for dataframe
138 (:export lists-of-same-size
141 make-dataframe-from-listoflist
142 make-array-from-listoflist
))
144 (defpackage :lisp-stat-model
145 (:documentation
"Model management for data analysis.")
149 ;; data structures for model and model/data combination
150 model statistical-model analysis
))
153 (defpackage :lisp-stat-regression-linear-clos
156 :lisp-stat-dataframe
)
157 (:export regression-model
))
160 (defpackage :lisp-stat-visualize
163 :lisp-stat-dataframe
))
165 (defpackage :lisp-stat-visualize-plplot
180 (defpackage :lisp-stat-ffi-int
183 (:export ccl-store-integer ccl-store-double ccl-store-ptr
186 (defpackage :lisp-stat-probability
191 (:export log-gamma set-seed
193 normal-cdf normal-quant normal-dens normal-rand
195 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
196 gamma-cdf gamma-quant gamma-dens gamma-rand
197 chisq-cdf chisq-quant chisq-dens chisq-rand
198 beta-cdf beta-quant beta-dens beta-rand
199 t-cdf t-quant t-dens t-rand
200 f-cdf f-quant f-dens f-rand
201 poisson-cdf poisson-quant poisson-pmf poisson-rand
202 binomial-cdf binomial-quant binomial-pmf binomial-rand
))
206 (defpackage :lisp-stat-math
208 :lisp-stat-object-system
210 :lisp-stat-compound-data
212 (:shadowing-import-from
:lisp-stat-object-system
213 call-method call-next-method
)
214 (:shadow expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
215 asin acos atan sinh cosh tanh asinh acosh atanh float random
216 truncate floor ceiling round minusp zerop plusp evenp oddp
217 < <= = /= >= > ;; complex
218 conjugate realpart imagpart phase
219 min max logand logior logxor lognot ffloor fceiling
220 ftruncate fround signum cis
)
221 (:export ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
222 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
223 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
225 conjugate realpart imagpart phase min max
226 logand logior logxor lognot ffloor fceiling ftruncate fround
228 (:documentation
"Vectorization of numerical functions"))
231 #|
;; some of this goes back in, but not all of it?
232 (defpackage :lisp-stat-linalg
239 :lisp-stat-compound-data
)
240 (:shadowing-import-from
:lisp-stat-math
241 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
242 asin acos atan sinh cosh tanh asinh acosh atanh float random
243 truncate floor ceiling round minusp zerop plusp evenp oddp
244 < <= = /= >= > complex conjugate realpart imagpart phase
245 min max logand logior logxor lognot ffloor fceiling
246 ftruncate fround signum cis
)
247 (:export chol-decomp lu-decomp lu-solve determinant inverse
248 sv-decomp qr-decomp rcondest make-rotation spline
249 kernel-dens kernel-smooth
250 fft make-sweep-matrix sweep-operator ax
+y eigen
252 check-real
;; for optimize
254 covariance-matrix matrix print-matrix solve
255 backsolve eigenvalues eigenvectors accumulate cumsum combine
263 (defpackage :lisp-stat-data
264 (:documentation
"Data management, integration, I/O, and other data technologies.")
265 (:nicknames
:ls-data
)
267 :lisp-stat-object-system
270 :lisp-stat-compound-data
)
271 (:shadowing-import-from
:lisp-stat-object-system
272 call-method call-next-method
)
273 (:export open-file-dialog read-data-file read-data-columns load-data
274 load-example
*variables
* *ask-on-redefine
*
275 def variables savevar undef
))
277 (defpackage :lisp-stat-descriptive-statistics
281 :lisp-stat-compound-data
284 (:shadowing-import-from
:lisp-stat-math
;; life is a vector!
285 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
286 asin acos atan sinh cosh tanh asinh acosh atanh float random
287 truncate floor ceiling round minusp zerop plusp evenp oddp
288 < <= = /= >= > ;; complex
289 conjugate realpart imagpart phase
290 min max logand logior logxor lognot ffloor fceiling
291 ftruncate fround signum cis
)
292 (:export standard-deviation
293 quantile median interquartile-range
297 (defpackage :lisp-stat-regression-linear
300 :lisp-stat-object-system
302 :lisp-stat-compound-data
303 :lisp-stat-descriptive-statistics
)
304 (:shadowing-import-from
:lisp-stat-object-system
305 call-method call-next-method
)
306 (:export regression-model fit-model
308 estimates covariation-matrix
309 ;; functions for helpers
314 regression-model-proto x y intercept
316 basis weights included
317 total-sum-of-squares residual-sum-of-squares
318 predictor-names response-name case-labels
321 (defpackage :lisp-stat
322 (:documentation
"Experimentation package for LispStat. Serious
323 work should be packaged up elsewhere for reproducibility. By this
324 I mean, creating a data/analytics/analysis package with the
325 minimal set of objects required.")
327 :lisp-stat-object-system
328 :lisp-stat-compound-data
329 :lisp-stat-probability
336 :lisp-matrix
;; conversion to a more robust linalg approach
337 :lisp-stat-descriptive-statistics
338 :lisp-stat-regression-linear
340 (:shadowing-import-from
:lisp-stat-object-system
341 call-method call-next-method
)
342 (:shadowing-import-from
:lisp-stat-math
343 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
344 asin acos atan sinh cosh tanh asinh acosh atanh float random
345 truncate floor ceiling round minusp zerop plusp evenp oddp
348 conjugate realpart imagpart phase
351 logand logior logxor lognot
352 ffloor fceiling ftruncate fround
361 fixnump check-nonneg-fixnum check-one-fixnum
362 check-one-nonneg-fixnum
363 check-one-real check-one-number
371 compound-data-p
*compound-data-proto
* compound-object-p
372 compound-data-seq compound-data-length
373 element-list element-seq
375 recursive-map-elements map-elements
378 get-next-element make-next-element set-next-element
386 ^
** expt
+ -
* / mod rem pmin pmax abs
1+ 1- log exp sqrt sin cos
387 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
388 truncate floor ceiling round minusp zerop plusp evenp oddp
< <= =
390 conjugate realpart imagpart phase min max
391 logand logior logxor lognot ffloor fceiling ftruncate fround
394 #|
;; The following need to be re-found in lisp-matrix...
397 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
398 column-list inner-product outer-product cross-product transpose
399 bind-columns bind-rows
402 chol-decomp lu-decomp lu-solve determinant inverse
403 sv-decomp qr-decomp rcondest make-rotation spline
404 kernel-dens kernel-smooth
405 fft make-sweep-matrix sweep-operator ax
+y eigen
407 covariance-matrix matrix print-matrix solve
408 backsolve eigenvalues eigenvectors accumulate cumsum combine
411 ;; in linalg.lisp, possibly not supported by matlisp
412 spline kernel-dens kernel-smooth
420 make-rv-function make-rv-function-1
423 open-file-dialog read-data-file read-data-columns load-data
424 load-example
*variables
* *ask-on-redefine
*
425 def variables savevar undef
428 dataframe-like dataframe-array make-dataframe
429 varlabels caselabels nrows ncols
430 dataframe-dimension dataframe-dimensons
431 dfref dfref-case dfref-var
432 consistent-dataframe-p
434 list-of-columns list-of-rows
437 lists-of-same-size equal-listoflist
439 make-dataframe-from-listoflist make-array-from-listoflist
441 ;; statistics.lsp (descriptions, should probably be moved
443 standard-deviation quantile median interquartile-range
446 ;; probability (dists.lisp)
448 uniform-rand normal-cdf normal-quant normal-dens
449 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
450 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
451 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
452 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
453 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
454 binomial-cdf binomial-quant binomial-pmf binomial-rand
456 ;; Here is where we have a problem -- lispstat core should be core
457 ;; data management and config problems, with packages providing
458 ;; specialized extensions to LispStat, i.e. regression, nonlin
459 ;; regression, bayesian regression via laplace approximation, etc.
461 ;; The following could be considered "recommended packages",
462 ;; similar to the idea of the recommended packages in R. Probably
463 ;; we want them to do the exporting within that package, therefore
464 ;; NOT being able to lock the "data-ish" package, but only the
465 ;; subpackages prior to export.
468 ;; -- linear regressin models.
469 regression-model fit-model
470 estimates covariation-matrix
472 regression-model-proto x y intercept sweep-matrix
473 basis weights included total-sum-of-squares residual-sum-of-squares
474 predictor-names response-name case-labels
478 ;; -- nonlinear regression models
479 nreg-model nreg-model-proto mean-function theta-hat epsilon
481 ;; we might need something like xtxinv here? But should be
482 ;; encapsulated, so we use the one in regression.lisp
485 bayes-model bayes-model-proto bayes-internals
498 ;;;; PACKAGES FOR USEABILITY
500 (defpackage :lisp-stat-data-examples
501 (:documentation
"Example data for unittests, examples, illustrations,")
504 (:shadowing-import-from
:lisp-stat
505 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
516 (:export iron aluminum absorbtion
520 (defpackage :lisp-stat-user
521 (:documentation
"Experimentation package for LispStat.
522 Serious work should be placed in a similar package elsewhere for
523 reproducibility. But this should hint as to what needs to be
524 done for a user- or analysis-package.")
525 (:nicknames
:ls-user
)
529 :lisp-stat-data-examples
) ;; this last is to have 'things to play with'
530 (:shadowing-import-from
:lisp-stat
531 call-method call-next-method
533 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
534 asin acos atan sinh cosh tanh asinh acosh atanh float random
535 truncate floor ceiling round minusp zerop plusp evenp oddp
536 < <= = /= >= > > ;; complex
537 conjugate realpart imagpart phase
538 min max logand logior logxor lognot ffloor fceiling
539 ftruncate fround signum cis
543 (defpackage :lisp-stat-unittests
544 (:use
:common-lisp
:lift
:lisp-stat
:lisp-stat-data-examples
)
545 (:shadowing-import-from
:lisp-stat
546 call-method call-next-method
;; objects
547 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
;; lsmath
548 asin acos atan sinh cosh tanh asinh acosh atanh float random
549 truncate floor ceiling round minusp zerop plusp evenp oddp
550 < <= = /= >= > ;; complex
551 conjugate realpart imagpart phase
552 min max logand logior logxor lognot ffloor fceiling
553 ftruncate fround signum cis
)
554 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard
; exec
555 almost
= almost
=lists numerical
=)) ; compare
557 (defpackage :lisp-stat-dataframe-example
559 :lift
:lisp-stat-unittests
560 :lisp-stat-data-examples
561 :lisp-stat-dataframe
)
562 (:export absorbtion aluminum iron
))
565 (defpackage :lisp-stat-optimize
570 :lisp-stat-object-system
572 :lisp-stat-compound-data
578 :lisp-stat-linalg-data
582 (:shadowing-import-from
:lisp-stat-object-system
583 call-method call-next-method
)
584 (:shadowing-import-from
:lisp-stat-math
585 expt
+ -
* / ** mod rem abs
1+ 1- log exp sqrt sin cos tan
586 asin acos atan sinh cosh tanh asinh acosh atanh float random
587 truncate floor ceiling round minusp zerop plusp evenp oddp
588 < <= = /= >= > complex conjugate realpart imagpart phase
589 min max logand logior logxor lognot ffloor fceiling
590 ftruncate fround signum cis
)
596 newtonmax nelmeadmax
))