blindglobe / common-lisp-stat

Common Lisp Statistics -- based on LispStat (Tierney) but updated for Common Lisp and incorporating lessons from R (http://www.r-project.org/)

This URL has Read+Write access

common-lisp-stat / TODO.lisp
100644 171 lines (130 sloc) 4.866 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
;;; -*- mode: lisp -*-
 
;;; Time-stamp: <2009-09-21 22:53:53 tony>
;;; Creation: <2008-09-08 08:06:30 tony>
;;; File: TODO.lisp
;;; Author: AJ Rossini <blindglobe@gmail.com>
;;; Copyright: (c) 2007-2008, AJ Rossini <blindglobe@gmail.com>. BSD.
;;; Purpose: Stuff that needs to be made working sits inside the
;;; progns... This file contains the current challenges to
;;; solve, including a description of the setup and the work
;;; to solve....
 
;;; What is this talk of 'release'? Klingons do not make software
;;; 'releases'. Our software 'escapes', leaving a bloody trail of
;;; designers and quality assurance people in its wake.
 
;;; SET UP
 
(in-package :cl-user)
 
(progn
  (defun init-CLS ()
 
    ;; core system
    ;;(asdf:oos 'asdf:load-op 'lisp-matrix)
    ;;(asdf:oos 'asdf:compile-op 'cls :force t)
    (asdf:oos 'asdf:load-op 'cls)
 
    ;; visualization
    (asdf:oos 'asdf:load-op 'cl-cairo2-x11)
    (asdf:oos 'asdf:load-op 'cl-2d)
    
    ;; doc reporting
    (asdf:oos 'asdf:load-op 'cl-pdf)
    (asdf:oos 'asdf:load-op 'cl-typesetting))
 
  ;; (asdf:oos 'asdf:load-op 'xarray)
  ;; (asdf:oos 'asdf:load-op 'cl-opengl)
  ;; (asdf:oos 'asdf:load-op 'tinaa)
 
  (init-CLS))
 
(in-package :lisp-stat-unittests)
 
;; tests = 80, failures = 7, errors = 21
(run-tests :suite 'lisp-stat-ut)
(describe (run-tests :suite 'lisp-stat-ut))
 
(describe 'lisp-stat-ut)
(documentation 'lisp-stat-ut 'type)
 
;; FIXME: Example: currently not relevant, yet
;; (describe (lift::run-test :test-case 'lisp-stat-unittests::create-proto
;; :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
 
(describe (lift::run-tests :suite 'lisp-stat-ut-dataframe))
(lift::run-tests :suite 'lisp-stat-ut-dataframe)
 
(describe (lift::run-test
:test-case 'lisp-stat-unittests::create-proto
:suite 'lisp-stat-unittests::lisp-stat-ut-proto))
 
(in-package :ls-user)
 
;;; Tasks working on...
 
#+nil
(progn
  ;; use of extension packages supporting versioning and validation of
  ;; CLOS objects?
  (asdf:oos 'asdf:load-op 'versioned-objects)
  (asdf:oos 'asdf:load-op 'validations))
 
#+nil
(progn
  ;; Syntax examples using lexical scope, closures, and bindings to
  ;; ensure a clean communication of results
  (with-data dataset ((dsvarname1 [usevarname1])
                      (dsvarname2 [usevarname2]))
      @body))
 
(defparameter *df-test*
  (make-instance 'dataframe-array
:storage #2A (('a "test0" 0 0d0)
('b "test1" 1 1d0)
('c "test2" 2 2d0)
('d "test3" 3 3d0)
('e "test4" 4 4d0))
:doc "test reality"
:case-labels (list "0" "1" "2" "3" "4")
:var-labels (list "symbol" "string" "integer" "double-float")
:var-types (list 'symbol 'string 'integer 'double-float)))
 
*df-test* ; but with SBCL, ints become floats?
 
(defun check-var (df colnum)
  (let ((nobs (xdim df 0)))
    (dotimes (i nobs)
      (check-type (xref df i colnum) (elt (var-types df) i)))))
 
(check-var *df-test* 0)
 
(xref *df-test* 1 2)
 
(integerp (xref *df-test* 1 2))
(floatp (xref *df-test* 1 2))
(integerp (xref *df-test* 1 3))
(type-of (xref *df-test* 1 3))
(floatp (xref *df-test* 1 3))
 
(type-of (vector 1 1d0))
 
 
 
(loop )
 
(xref *df-test* 2 1)
(xref *df-test* 0 0)
(xref *df-test* 1 0)
(xref *df-test* 1 '*)
 
;;; Experiments with cl-variates
 
;; (asdf:oos 'asdf:compile-op 'cl-variates :force t)
;; (asdf:oos 'asdf:compile-op 'cl-variates-test :force t)
;; (asdf:oos 'asdf:load-op 'lift)
;; (asdf:oos 'asdf:load-op 'cl-variates)
(asdf:oos 'asdf:load-op 'cl-variates-test)
 
(in-package :cl-variates-test)
;; check tests
(run-tests :suite 'cl-variates-test)
(describe (run-tests :suite 'cl-variates-test))
 
(in-package :cl-variates-user)
;; example usage
(defparameter state (make-random-number-generator))
(setf (random-seed state) 44)
(random-seed state)
(loop for i from 1 to 10 collect
                  (random-range state 0 10))
;; => (1 5 1 0 7 1 2 2 8 10)
(setf (random-seed state) 44)
(loop for i from 1 to 10 collect
                  (random-range state 0 10))
;; => (1 5 1 0 7 1 2 2 8 10)
 
(setf (random-seed state) 44)
(random-seed state)
(loop for i from 1 to 10 collect
                  (normal-random state 0 1))
;; =>
;; (-1.2968656102820426 0.40746363934173213 -0.8594712469518473 0.8795681301148328
;; 1.0731526250004264 -0.8161629082481728 0.7001813608754809 0.1078045427044097
;; 0.20750134211656893 -0.14501914108452274)
 
(setf (random-seed state) 44)
(loop for i from 1 to 10 collect
                  (normal-random state 0 1))
;; =>
;; (-1.2968656102820426 0.40746363934173213 -0.8594712469518473 0.8795681301148328
;; 1.0731526250004264 -0.8161629082481728 0.7001813608754809 0.1078045427044097
;; 0.20750134211656893 -0.14501914108452274)
 
 
;;; experiments with LLA
(in-package :cl-user)
(asdf:oos 'asdf:load-op 'lla)
(in-package :lla-user)