2 Time-stamp: <2012-10-06 08:52:25 tony>
3 Creation: <2008-09-08 08:06:30 tony>
8 Author: AJ Rossini <blindglobe@gmail.com>
9 Copyright: (c) 2007-2010, AJ Rossini <blindglobe@gmail.com>. BSD.
10 Purpose: Stuff that needs to be made working sits inside the
13 This file contains the current challenges to solve,
14 including a description of the setup and the work to
15 solve. Solutions welcome.
17 What is this talk of 'release'? Klingons do not make software
18 'releases'. Our software 'escapes', leaving a bloody trail of
19 designers and quality assurance people in its wake.
21 * Design Documentation
23 This section provides some of the details regarding infrastructure of
24 the system, as a means of including TODO statements.
26 ** (Internal) Package and (External) System Hierarchy
28 current (possibly incomplete) set of lisp dependencies <2012-10-04 Thu>
30 0 ~/sandbox/xarray.git
31 1 ~/sandbox/foreign-numeric-vector.git
32 2 ~/sandbox/trivial-features.git
33 3 ~/sandbox/alexandria.git
36 6 ~/sandbox/cl-utilities
37 7 ~/sandbox/metabang-bind.git
38 8 ~/sandbox/iterate.git
39 9 ~/sandbox/array-operations.git
42 *** Singletons (primary building blocks)
44 These are packages as well as
46 | asdf | common system loader |
47 | xarray | common access structure to array-like |
48 | | (matrix, vector) structures. |
49 | cls-config | initialization of Lisp state, variables, etc, |
50 | | localization to the particular lisp. |
51 | lift | unit-testing |
52 | cffi | foriegn function library |
58 as of now, all are in QL heirarchy
60 *** Dependency structure
62 | lisp-matrix | general purpose matrix package, linking to lapack | |
63 | | for numerics. Depends on: | |
66 | | cl-blapack | cffi |
68 | cls-dataframe | in the same spirit as lisp-matrix, a means to | |
69 | | create tables. Perhaps better called datatables? | |
70 | cls-probability | depends on gsll, cl-variates, cl-? initially, | |
74 **** Random number streams and probability calculus
77 Something for random numbers, that has a settable seed. However,
78 we could pass on the "right thing" in favor of something that
82 **** import of data in text files
84 CSV and similar specialized imports
98 Usually, we need to load it before going on.
108 though sometimes we might want to recompile fully. (Can this be
109 done via QL? Need to check)
111 #+name: compile-it-all
113 (asdf:oos 'asdf:compile-op :cls :force T)
118 - State "DONE" from "CURR" [2010-10-12 Tue 13:48] \\
119 setup is mostly complete
120 - State "CURR" from "TODO" [2010-10-12 Tue 13:47]
121 - State "TODO" from "" [2010-10-12 Tue 13:47]
123 This is an example of a custom setup, not really interesting at
124 this point (it's obsolete) except to remind Tony how to program.
125 Pointy-headed managers need any support they can find in order to
126 regress to their hacker-childhood.
130 (in-package :cl-user)
132 (defun init-CLS (&key (compile 'nil))
133 (let ((packagesToLoad (list ;; core system
134 :lift :lisp-matrix :cls
136 ;; :cl-cairo2-x11 :iterate
139 :cl-pdf :cl-typesetting
141 :asdf-system-connections :xarray
143 :metatilities-base :anaphora :tinaa
144 :cl-ppcre :cl-markdown :docudown
145 ;; version and validate CLOS objects
146 ;; :versioned-objects :validations
149 ;; :cl-glu :cl-glut :cl-glut-examples
154 (mapcar #'(lambda (x)
156 (asdf:oos 'asdf:compile-op x :force T)
157 (asdf:oos 'asdf:load-op x)))
160 (init-CLS)) ;; vs (init-CLS :compile T)
164 | | #<PACKAGE "COMMON-LISP-USER"> |
166 ** TODO [#A] Integrate with quicklist support.
167 - State "TODO" from "" [2010-11-30 Tue 18:00]
169 important to merge with quicklisp system loader support.
170 ** CURR [#A] Testing: unit, regression, examples. [0/3]
171 - State "CURR" from "TODO" [2010-10-12 Tue 13:51]
172 - State "TODO" from "" [2010-10-12 Tue 13:51]
173 Testing consists of unit tests, which internally verify subsets of
174 code, regression tests, and functional tests (in increasing order
176 *** CURR [#B] Unit tests
177 - State "CURR" from "TODO" [2010-11-04 Thu 18:33]
178 - State "CURR" from "TODO" [2010-10-12 Tue 13:48]
179 - State "TODO" from "" [2010-10-12 Tue 13:48]
180 Unit tests have been started using LIFT. Need to consider some of
181 the other systems that provide testing, when people add them to the
182 mix of libraries that we need, along with examples of how to use.
184 #+name: ex-cls-unittest
186 (in-package :lisp-stat-unittests)
187 (run-tests :suite 'lisp-stat-ut)
191 : #<Results for LISP-STAT-UT 78 Tests, 7 Failures, 20 Errors>
193 ;; => tests = 78, failures = 7, errors = 20
197 The following needs to be solved in order to have a decent
198 installation qualification (IQ) and performance qualification (PQ)
202 (in-package :lisp-stat-unittests)
203 (asdf:oos 'asdf:test-op 'cls)
204 ;; which runs (describe (run-tests :suite 'lisp-stat-ut))
209 and check documentation to see if it is useful.
212 (in-package :lisp-stat-unittests)
214 (describe 'lisp-stat-ut)
215 (documentation 'lisp-stat-ut 'type)
217 ;; FIXME: Example: currently not relevant, yet
218 ;; (describe (lift::run-test :test-case 'lisp-stat-unittests::create-proto
219 ;; :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
221 (describe (lift::run-tests :suite 'lisp-stat-ut-dataframe))
222 (lift::run-tests :suite 'lisp-stat-ut-dataframe)
224 (describe (lift::run-test
225 :test-case 'lisp-stat-unittests::create-proto
226 :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
229 *** TODO [#B] Regression Tests
230 - State "TODO" from "" [2010-10-12 Tue 13:54]
232 *** TODO [#B] Functional Tests
233 - State "TODO" from "" [2010-10-12 Tue 13:54]
235 ** CURR [#B] Functional Examples that need to work [1/3]
236 - State "CURR" from "TODO" [2010-11-30 Tue 17:57]
237 - State "TODO" from "" [2010-10-12 Tue 13:55]
239 These examples should be functional forms within CLS, describing
240 working functionality which is needed for work.
241 *** TODO [#A] Dataframe creation
242 Illustration via a file, that we need to get working so that we
243 can get data in-and-out of CLS structures.
245 #+BEGIN_SRC lisp :export examples/example-DF-creation.lisp
246 ;;; -*- mode: lisp -*-
247 ;;; Copyright (c) 2006-2012, by A.J. Rossini <blindglobe@gmail.com>
248 ;;; See COPYRIGHT file for any additional restrictions (BSD license).
249 ;;; Since 1991, ANSI was finally finished. Edited for ANSI Common Lisp.
251 ;;; Time-stamp: <2012-10-04 02:16:45 tony>
252 ;;; Creation: <2012-07-01 11:29:42 tony>
253 ;;; File: example.lisp
254 ;;; Author: AJ Rossini <blindglobe@gmail.com>
255 ;;; Copyright: (c) 2012, AJ Rossini. BSD.
256 ;;; Purpose: example of possible usage.
258 ;;; What is this talk of 'release'? Klingons do not make software
259 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
260 ;;; designers and quality assurance people in its wake.
266 ;; use the example package...
267 (in-package :cls-user)
270 ;; or better yet, create a package/namespace for the particular problem being attacked.
271 (defpackage :my-package-user
272 (:documentation "demo of how to put serious work should be placed in
273 a similar package elsewhere for reproducibility. This hints as to
274 what needs to be done for a user- or analysis-package.")
275 (:nicknames :my-clswork-user)
276 (:use :common-lisp ; always needed for user playgrounds!
277 :lisp-matrix ; we only need the packages that we need...
278 :common-lisp-statistics
279 :lisp-stat-data-examples) ;; this ensures access to a data package
280 (:export summarize-data summarize-results this-data this-report)
281 (:shadowing-import-from :lisp-stat call-method call-next-method
283 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
284 asin acos atan sinh cosh tanh asinh acosh atanh float random
285 truncate floor ceiling round minusp zerop plusp evenp oddp
286 < <= = /= >= > > ;; complex
287 conjugate realpart imagpart phase
288 min max logand logior logxor lognot ffloor fceiling
289 ftruncate fround signum cis
293 (in-package :my-clswork-user)
295 ;; create some data by hand using arrays, and demonstrate access.
297 (let ((myArray #2A((1 2 3)(4 5 6)))
298 (myDF (make-dataframe #2A((1 2 3)(4 5 6))))
299 (myLOL (list (list 1 2 3) (list 4 5 6)))
300 ;; FIXME: listoflist conversion does not work.
301 ;; (myDFlol (make-dataframe '(list ((1 2 3)(4 5 6)))))
304 (= (xref myArray 1 1)
309 *** TODO [#B] Scoping with datasets
310 - State "TODO" from "" [2010-11-04 Thu 18:46]
312 The following needs to work, and a related syntax for resampling
313 and similar synthetic data approaches (bootstrapping, imputation)
314 ought to use similar syntax as well.
315 #+name: DataSetNameScoping
317 (in-package :ls-user)
319 ;; Syntax examples using lexical scope, closures, and bindings to
320 ;; ensure a clean communication of results
321 ;; This is actually a bit tricky, since we need to clarify whether
322 ;; it is line-at-a-time that we are considering or if there is
323 ;; another mapping strategy. In particular, one could imagine a
324 ;; looping-over-observations function, or a
325 ;; looping-over-independent-observations function which leverages a
326 ;; grouping variable which provides guidance for what is considered
327 ;; independent from the sampling frame being considered. The frame
328 ;; itself (definable via some form of metadata to clarify scope?)
329 ;; could clearly provide a bit of relativity for clarifying what
330 ;; statistical independence means.
332 (with-data dataset ((dsvarname1 [usevarname1])
333 (dsvarname2 [usevarname2]))
336 ;; SAS-centric approach to spec'ing work
337 (looping-over-observations
338 dataset ((dsvarname1 [usevarname1])
339 (dsvarname2 [usevarname2]))
342 ;; SAS plus "statistical sensibility"... for example, if an
343 ;; independent observation actually consists of many observations so
344 ;; that a dataframe of independence results -- for example,
345 ;; longitudinal data or spatial data or local-truncated network data
346 ;; are clean examples of such happening -- then we get the data
347 ;; frame or row representing the independent result.
348 (looping-over-independent-observations
349 dataset independence-defining-variable
350 ((dsvarname1 [usevarname1])
351 (dsvarname2 [usevarname2]))
356 *** DONE [#B] Dataframe variable typing
357 - State "DONE" from "CURR" [2010-11-30 Tue 17:56] \\
358 check-type approach works, we would just have to throw a catchable
359 error if we want to use it in a reliable fashion.
360 - State "CURR" from "TODO" [2010-11-30 Tue 17:56]
361 - State "TODO" from "" [2010-11-04 Thu 18:48]
363 Seems to generally work, need to ensure that we use this for
368 (in-package :ls-user)
369 (defparameter *df-test*
370 (make-instance 'dataframe-array
371 :storage #2A (('a "test0" 0 0d0)
377 :case-labels (list "0" "1" 2 "3" "4")
378 :var-labels (list "symbol" "string" "integer" "double-float")
379 :var-types (list 'symbol 'string 'integer 'double-float)))
381 ;; with SBCL, ints become floats? Need to adjust output
382 ;; representation appropriately..
385 (defun check-var (df colnum)
386 (let ((nobs (xdim (dataset df) 0)))
388 (check-type (xref df i colnum) (elt (var-types df) i)))))
390 (xdim (dataset *df-test*) 1)
391 (xdim (dataset *df-test*) 0)
393 (check-var *df-test* 0)
396 (xref *df-test* 1 1))
398 (check-type (xref *df-test* 1 1)
399 string) ;; => nil, so good.
400 (check-type (xref *df-test* 1 1)
401 vector) ;; => nil, so good.
402 (check-type (xref *df-test* 1 1)
403 real) ;; => simple-error type thrown, so good.
405 ;; How to nest errors within errors?
406 (check-type (check-type (xref *df-test* 1 1) real) ;; => error thrown, so good.
410 (check-type *df-test*
411 dataframe-array) ; nil is good.
413 (integerp (xref *df-test* 1 2))
414 (floatp (xref *df-test* 1 2))
415 (integerp (xref *df-test* 1 3))
416 (type-of (xref *df-test* 1 3))
417 (floatp (xref *df-test* 1 3))
419 (type-of (vector 1 1d0))
425 (xref *df-test* 1 '*)
428 ** CURR [#A] Random Numbers [2/6]
429 - State "CURR" from "TODO" [2010-11-05 Fri 15:41]
430 - State "TODO" from "" [2010-10-14 Thu 00:12]
432 Need to select and choose a probability system (probability
433 functions, random numbers). Goal is to have a general framework
434 for representing probability functions, functionals on
435 probabilities, and reproducible random streams based on such
437 *** CURR [#B] CL-VARIATES system evaluation [2/3]
438 - State "CURR" from "TODO" [2010-11-05 Fri 15:40]
439 - State "TODO" from "" [2010-10-12 Tue 14:16]
441 CL-VARIATES is a system developed by Gary W King. It uses streams
442 with seeds, and is hence reproducible. (Random comment: why do CL
443 programmers as a class ignore computational reproducibility?)
445 The main problem with this system is licensing. It has a weird
446 licensing schema which prevents
448 #+name: Loading-CL-VARIATES
450 (in-package :cl-user)
451 (ql:quickload :cl-variates)
452 ;;(ql:quickload :cl-variates-test)
455 #+name: CL-VARIATES-UNITTESTS
457 (in-package :cl-variates-test)
459 (run-tests :suite 'cl-variates-test)
460 (describe (run-tests :suite 'cl-variates-test))
463 basic example of reproducible draws from the uniform and normal
464 random number streams.
466 #+name: CL-VARIATES-REPRO
469 (in-package :cl-variates-user)
471 (defparameter state (make-random-number-generator))
472 (setf (random-seed state) 44)
475 (loop for i from 1 to 10 collect
476 (random-range state 0 10))
477 ;; => (1 5 1 0 7 1 2 2 8 10)
478 (setf (random-seed state) 44)
479 (loop for i from 1 to 10 collect
480 (random-range state 0 10))
481 ;; => (1 5 1 0 7 1 2 2 8 10)
483 (setf (random-seed state) 44)
485 (loop for i from 1 to 10 collect
486 (normal-random state 0 1))
488 ;; (-1.2968656102820426 0.40746363934173213 -0.8594712469518473 0.8795681301148328
489 ;; 1.0731526250004264 -0.8161629082481728 0.7001813608754809 0.1078045427044097
490 ;; 0.20750134211656893 -0.14501914108452274)
492 (setf (random-seed state) 44)
493 (loop for i from 1 to 10 collect
494 (normal-random state 0 1))
496 ;; (-1.2968656102820426 0.40746363934173213 -0.8594712469518473 0.8795681301148328
497 ;; 1.0731526250004264 -0.8161629082481728 0.7001813608754809 0.1078045427044097
498 ;; 0.20750134211656893 -0.14501914108452274)
502 **** CURR [#B] Full example of general usage
503 - State "CURR" from "TODO" [2010-11-05 Fri 15:40]
504 - State "TODO" from "" [2010-11-05 Fri 15:40]
506 What we want to do here is describe the basic available API that
507 is present. So while the previous work describes what the basic
508 reproducibility approach would be in terms of generating lists of
509 reproducible pRNG streams, we need the full range of possible
510 probability laws that are present.
512 One of the good things about cl-variates is that it provides for
513 reproducibility. One of the bad things is that it has a mixed
516 *** TODO [#B] CL-RANDOM system evaluation
517 - State "TODO" from "" [2010-11-05 Fri 15:40]
520 1. no seed setting for random numbers
521 2. contamination of a probability support with optimization and
526 2. nice design for generics.
528 *** TODO [#B] Native CLS (from XLS)
529 - State "TODO" from "" [2010-11-05 Fri 15:40]
531 ** TODO [#B] Numerical Linear Algebra
532 - State "TODO" from "" [2010-10-14 Thu 00:12]
534 *** TODO [#B] LLA evaluation
535 - State "TODO" from "" [2010-10-12 Tue 14:13]
537 LLA is an SBCL targetted linear algebra library from Tamas Papp
539 #+NAME LLA-experiments
541 (in-package :cl-user)
542 (asdf:oos 'asdf:load-op 'lla)
543 (in-package :lla-user)
547 *** CURR [#B] Lisp-Matrix system evaluation
548 - State "CURR" from "TODO" [2010-10-12 Tue 14:13]
549 - State "TODO" from "" [2010-10-12 Tue 14:13]
553 *** TODO [#B] LispLab system evaluation
554 - State "TODO" from "" [2010-10-12 Tue 14:13]
556 LL is an SBCL targetted linear algebra library from ---
558 ** TODO [#B] Statistical Procedures to implement
559 - State "TODO" from "" [2010-10-14 Thu 00:12]
565 (in-package :cls-user)
570 ;; population design eval and opt
578 number of samples/cost of lab analysis and collection
582 (defun pfim (&key model ( constraints ( summary-function )
584 (list num-subjects num-times list-times))))
588 Each individal has a deisgn psi_i
589 nubmer of samples n_i and sampling times t_{i{1}} t_{i{n_1}}
590 individuals can differ
594 individual-level model
597 (=model y_i (+ (f \theta_i \psi_i) epsilion_i ))
598 (=var \epsilion_i \sigma_between \sigma_within )
600 ;; Information Matrix for pop deisgn
602 (defparameter IM (sum (i 1 N) (MF \psi_i \phi_i)))
605 For nonlinear structureal models, expand around RE=0
607 Cramer-Rao : MF^{-1} is lower bound for estimation variance.
611 - smallest SE, but is a matrix, so
612 - criteria for matrix comparison
613 -- D-opt, (power (determinant MF) (/ 1 P))
616 find design maxing D opt, (power (determinant MF) (/ 1 P))
618 -- contin vars for smapling times within interval or set -- number of groups for cat vars
620 Stat in Med 2009, expansion around post-hoc RE est, not necessarily zero.
622 Example binary covariate C
625 (if (= i reference-class)
630 (=model (log \theta) ( ))
637 PFIM provides for a given design and values of \beta:
639 SE/RSE for \beta of each class of each covar
640 eval influence of design on SE(\beta)
642 inter-occassion variability (IOV)
643 - patients sampled more than once, H occassions
645 - additional vars to estimate
649 ;;; comparison criteria
651 functional of conc/time curve which is used for comparison, i.e.
652 (AUC conc/time-curve)
653 (Cmax conc/time-curve)
654 (Tmax conc/time-curve)
658 (defun conc/time-curve (t)
661 (let ((conc (exp (* t \beta1))))
667 (url-get "www.pfim.biostat.fr")
670 ;;; Thinking of generics...
671 (information-matrix model parameters)
672 (information-matrix variance-matrix)
673 (information-matrix model data)
674 (information-matrix list-of-individual-IMs)
677 (defun IM (loglikelihood parameters times)
678 "Does double work. Sum up the resulting IMs to form a full IM."
679 (let ((IM (make-matrix (length parameters)
681 :initial-value 0.0d0)))
682 (dolist (parameterI parameters)
683 (dolist (parameterJ parameters)
685 (differentiate (differentiate loglikelihood parameterI) parameterJ))))))
688 *** difference between empirical, fisherian, and ...? information.
689 *** TODO [#C] Example of Integration with CL-GENOMIC
690 - State "TODO" from "" [2010-10-12 Tue 14:03]
692 CL-GENOMIC is a very interesting data-structure strategy for
693 manipulating sequence data.
697 (in-package :cl-user)
698 (asdf:oos 'asdf:compile-op :ironclad)
699 (asdf:oos 'asdf:load-op :cl-genomic)
701 (in-package :bio-sequence)
702 (make-dna "agccg") ;; fine
703 (make-aa "agccg") ;; fine
704 (make-aa "agc9zz") ;; error expected
708 ** TODO [#B] Documentation and Examples [0/3]
709 - State "TODO" from "" [2010-10-14 Thu 00:12]
711 *** TODO [#B] Docudown
712 - State "TODO" from "" [2010-11-05 Fri 15:34]
715 - State "TODO" from "" [2010-11-05 Fri 15:34]
717 *** TODO [#B] CLPDF, and literate data analysis
718 - State "TODO" from "" [2010-11-05 Fri 15:34]
721 Place proposals for features, work, etc here...
722 ** <2011-12-29 Thu> new stuff
723 First new proposal is to track proposals.
727 This project is dedicated to all the lisp hackers out there who
728 provided the basic infrastructure to get so far so fast with minimal
731 And to all the people trying to help to get this off the ground.