3 ;;; Time-stamp: <2009-04-28 13:10:21 tony>
4 ;;; Creation: <2008-09-08 08:06:30 tony>
6 ;;; Author: AJ Rossini <blindglobe@gmail.com>
7 ;;; Copyright: (c) 2007-2008, AJ Rossini <blindglobe@gmail.com>. BSD.
8 ;;; Purpose: Stuff that needs to be made working sits inside the
9 ;;; progns... This file contains the current challenges to
10 ;;; solve, including a description of the setup and the work
13 ;;; What is this talk of 'release'? Klingons do not make software
14 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
15 ;;; designers and quality assurance people in its wake.
20 ;;(asdf:oos 'asdf:load-op 'lisp-matrix)
21 ;;(asdf:oos 'asdf:compile-op 'lispstat :force t)
22 ;;(asdf:oos 'asdf:load-op 'lispstat)
24 (in-package :lisp-stat-unittests
)
26 ;; tests = 80, failures = 8, errors = 15
27 (run-tests :suite
'lisp-stat-ut
)
28 (describe (run-tests :suite
'lisp-stat-ut
))
30 ;; FIXME: Example: currently not relevant, yet
31 ;; (describe (lift::run-test :test-case 'lisp-stat-unittests::create-proto
32 ;; :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
34 (describe (lift::run-tests
:suite
'lisp-stat-ut-dataframe
))
35 (lift::run-tests
:suite
'lisp-stat-ut-dataframe
)
39 :test-case
'lisp-stat-unittests
::create-proto
40 :suite
'lisp-stat-unittests
::lisp-stat-ut-proto
))
42 (describe 'lisp-stat-ut
)
47 ;; Plotting -- need to figure out the core-dump, or change libraries.
48 ;; (asdf:oos 'asdf:load-op 'cl-plplot)
51 (defparameter *gdev
* "xcairo")
52 ;; (defparameter *gdev* "xwin")
53 (cl-plplot::plsdev
*gdev
*)
55 ;; there is currently a loose pointer floating around that causes
56 ;; errors the 3rd time that we create a plot (and crashes SBCL the
57 ;; 4th time). Order independent.
65 ;; REVIEW: general Lisp use guidance
67 (fdefinition 'make-matrix
)
68 (documentation 'make-matrix
'function
)
70 #| Examples from CLHS
, a bit of guidance.
72 ;; This function assumes its callers have checked the types of the
73 ;; arguments, and authorizes the compiler to build in that assumption.
74 (defun discriminant (a b c
)
75 (declare (number a b c
))
76 "Compute the discriminant for a quadratic equation."
77 (- (* b b
) (* 4 a c
))) => DISCRIMINANT
78 (discriminant 1 2/3 -
2) => 76/9
80 ;; This function assumes its callers have not checked the types of the
81 ;; arguments, and performs explicit type checks before making any assumptions.
82 (defun careful-discriminant (a b c
)
83 "Compute the discriminant for a quadratic equation."
87 (locally (declare (number a b c
))
88 (- (* b b
) (* 4 a c
)))) => CAREFUL-DISCRIMINANT
89 (careful-discriminant 1 2/3 -
2) => 76/9
95 (progn ;; experiments with GSL and the Lisp interface.
96 (asdf:oos
'asdf
:load-op
'gsll
)
97 (asdf:oos
'asdf
:load-op
'gsll-tests
)
99 ;; the following should be equivalent
100 (defparameter *t1
* (LIST 6.18d0
6.647777777777779d0
6.18d0
))
101 (defparameter *t2
* (MULTIPLE-VALUE-LIST
103 (gsll:make-marray
'DOUBLE-FLOAT
104 :INITIAL-CONTENTS
'(-3.21d0
1.0d0
12.8d0
)))
106 (gsll:MAKE-MARRAY
'DOUBLE-FLOAT
107 :INITIAL-CONTENTS
'(3.0d0
1.0d0
2.0d0
))))
108 (LET ((MEAN (gsll:MEAN VEC
)))
109 (LIST (gsll:ABSOLUTE-DEVIATION VEC
)
110 (gsll:WEIGHTED-ABSOLUTE-DEVIATION VEC WEIGHTS
)
111 (gsll:ABSOLUTE-DEVIATION VEC MEAN
))))))
114 ;; from (gsll:examples 'gsll::numerical-integration) ...
115 (gsll:integration-qng gsll
::one-sine
0.0d0 PI
)
117 (gsll:defun-single axpb
(x) (+ (* 2 x
) 3)) ;; a<-2, b<-3
118 (gsll:integration-qng axpb
1d0
2d0
)
122 (defun-single axpb2
(x) (+ (* a x
) b
)))
123 (gsll:integration-qng axpb2
1d0
2d0
)
126 ;; (gsll:integration-qng
129 ;; (defun-single axpb2 (x) (+ (* a x) b)))
132 ;; right, but weird expansion...
133 (gsll:integration-qng
136 (defun axpb2 (x) (+ (* a x
) b
))
137 (gsll:def-single-function axpb2
)
141 ;; Linear least squares
143 (gsll:gsl-lookup
"gsl_linalg_LU_decomp") ; => gsll:lu-decomposition
144 (gsll:gsl-lookup
"gsl_linalg_LU_solve") ; => gsll:lu-solve
150 (progn ;; philosophy time
152 (setf my-model
(model :name
"ex1"
153 :data-slots
(list w x y z
)
154 :param-slots
(list alpha beta gamma
)
155 :math-form
(regression-model :formula
'(= w
(+ (* beta x
)
159 :centrality
'median
; 'mean
166 (setf my-dataset
(statistical-table :table data-frame-contents
167 :metadata
(list (:case-names
(list ))
169 (:documentation
"string of doc"))))
171 (setf my-analysis
(analysis
174 :parameter-map
(pairing (model-param-slots my-model
)
175 (data-var-names my-dataset
))))
177 ;; ontological implications -- the analysis is an abstract class of
178 ;; data, model, and mapping between the model and data. The fit is
179 ;; the instantiation of such. This provides a statistical object
180 ;; computation theory which can be realized as "executable
181 ;; statistics" or "computable statistics".
182 (setf my-analysis
(analyze my-fit
183 :estimation-method
'linear-least-squares-regression
))
185 ;; one of the tricks here is that one needs to provide the structure
186 ;; from which to consider estimation, and more importantly, the
187 ;; validity of the estimation.
190 (setf linear-least-squares-regression
191 (estimation-method-definition
192 :variable-defintions
((list
193 ;; from MachLearn: supervised,
195 :data-response-vars list-drv
; nil if unsup
198 :data-predictor-vars list-dpv
199 ;; nil in this case. these
200 ;; describe "out-of-box" specs
201 :hyper-vars list-hv
))
202 :form
'(regression-additive-error
203 :central-form
(linear-form drv pv dpv
)
204 :error-form
'normal-error
)
205 :resulting-decision
'(point-estimation interval-estimation
)
206 :philosophy
'frequentist
207 :documentation
"use least squares to fit a linear regression
210 (defparameter *statistical-philosophies
*
211 '(frequentist bayesian fiducial decision-analysis
)
212 "can be combined to build decision-making approaches and
215 (defparameter *decisions
*
216 '(estimation selection testing
)
217 "possible results from a...")
218 ;; is this really true? One can embedded hypothesis testing within
219 ;; estimation, as the hypothesis estimated to select. And
220 ;; categorical/continuous rear their ugly heads, but not really in
223 (defparameter *ontology-of-decision-procedures
*
227 (list :maximum-likelihood
232 (list :maximum-likelihood
238 :bioequivalence-inversion
)
243 :partially-parametric
))
244 "start of ontology"))