Commit 4e6d5886 authored by Liam Healy's avatar Liam Healy

Restoration of tests complete except for arrays

All the lisp-unit tests defined in the old GSLL have been updated and
will load by default, with all tests passing on Debian Lenny amd64 and
GSL 1.11.
TOTAL: 491 assertions passed, 0 failed, 0 execution errors.
parent d0d17af0
;; Combinations
;; Liam Healy, Sun Mar 26 2006 - 11:51
;; Time-stamp: <2008-07-14 23:02:03EDT combination.lisp>
;; Time-stamp: <2008-09-20 22:04:48EDT combination.lisp>
;; $Id$
(in-package :gsl)
......@@ -194,44 +194,40 @@
while (combination-next comb)))))
|#
#|
(LISP-UNIT:DEFINE-TEST COMBINATION
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST 4)
(MULTIPLE-VALUE-LIST
(LETM ((COMB (COMBINATION 4 2 T)))
(LETM ((COMB (COMBINATION '(4 2) T)))
(COMBINATION-RANGE COMB))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST 2)
(MULTIPLE-VALUE-LIST
(LETM ((COMB (COMBINATION 4 2 T)))
(LETM ((COMB (COMBINATION '(4 2) T)))
(COMBINATION-SIZE COMB))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST
(LIST (LIST 0 1) (LIST 0 2) (LIST 0 3) (LIST 1 2)
(LIST 1 3) (LIST 2 3)))
(LIST (LIST #(0 1) #(0 2) #(0 3) #(1 2) #(1 3) #(2 3)))
(MULTIPLE-VALUE-LIST
(LETM ((COMB (COMBINATION 4 2 T))) (INIT-FIRST COMB)
(LOOP COLLECT (DATA COMB) WHILE
(COMBINATION-NEXT COMB)))))
(LETM ((COMB (COMBINATION '(4 2) T)))
(INIT-FIRST COMB)
(LOOP COLLECT (COPY-SEQ (CL-ARRAY COMB)) WHILE
(COMBINATION-NEXT COMB)))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST (LIST (LIST 2 3) (LIST 1 3) (LIST 1 2) (LIST 0 3)
(LIST 0 2) (LIST 0 1)))
(LIST (LIST #(2 3) #(1 3) #(1 2) #(0 3) #(0 2) #(0 1)))
(MULTIPLE-VALUE-LIST
(LETM ((COMB (COMBINATION 4 2 T))) (INIT-LAST COMB)
(LOOP COLLECT (DATA COMB) WHILE
(COMBINATION-PREVIOUS COMB)))))
(LETM ((COMB (COMBINATION '(4 2) T))) (INIT-LAST COMB)
(LOOP COLLECT (COPY-SEQ (CL-ARRAY COMB)) WHILE
(COMBINATION-PREVIOUS COMB)))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST
(LIST (LIST) (LIST 0) (LIST 1) (LIST 2) (LIST 3)
(LIST 0 1) (LIST 0 2) (LIST 0 3) (LIST 1 2)
(LIST 1 3) (LIST 2 3) (LIST 0 1 2) (LIST 0 1 3)
(LIST 0 2 3) (LIST 1 2 3) (LIST 0 1 2 3)))
(LIST #() #(0) #(1) #(2) #(3) #(0 1) #(0 2) #(0 3)
#(1 2) #(1 3) #(2 3) #(0 1 2) #(0 1 3) #(0 2 3)
#(1 2 3) #(0 1 2 3)))
(MULTIPLE-VALUE-LIST
(LOOP FOR I FROM 0 TO 4 APPEND
(LETM ((COMB (COMBINATION 4 I T)))
(INIT-FIRST COMB)
(LOOP COLLECT (DATA COMB) WHILE
(COMBINATION-NEXT COMB)))))))
|#
(LETM ((COMB (COMBINATION (LIST 4 I) T)))
(INIT-FIRST COMB)
(LOOP COLLECT (COPY-SEQ (CL-ARRAY COMB))
WHILE (COMBINATION-NEXT COMB)))))))
;; Permutations
;; Liam Healy, Sun Mar 26 2006 - 11:51
;; Time-stamp: <2008-07-12 14:12:36EDT permutation.lisp>
;; Time-stamp: <2008-09-20 21:59:49EDT permutation.lisp>
;; $Id$
(in-package :gsl)
......@@ -269,12 +269,12 @@
(letm ((perm-1 (permutation 4 t))) ;maref
(set-identity perm-1)
(maref perm-1 2))
(letm ((perm-1 (permutation 4 t))) ;data
(letm ((perm-1 (permutation 4 t))) ;cl-array
(set-identity perm-1)
(data perm-1))
(cl-array perm-1))
(letm ((perm-1 (permutation 4 t))) ;permutation-reverse
(set-identity perm-1)
(data (permutation-reverse perm-1)))
(cl-array (permutation-reverse perm-1)))
(letm ;permutation-next, permutation-inverse
((perm-1 (permutation 4 t)) (perm-2 (permutation 4 t)))
(set-identity perm-1)
......@@ -282,18 +282,18 @@
(permutation-next perm-1)
(permutation-next perm-1)
(permutation-inverse perm-2 perm-1)
(data perm-2))
(cl-array perm-2))
(letm ((perm-1 (permutation 4 t))) ;swap-elements
(set-identity perm-1)
(swap-elements perm-1 1 3)
(data perm-1))
(cl-array perm-1))
(letm ((perm-1 (permutation 4 t)) ;permute-vector
(intvec (vector-fixnum #(11 22 33 44))))
(intvec (vector-signed-byte-32 (a 11 22 33 44))))
(set-identity perm-1)
(swap-elements perm-1 1 3)
(swap-elements perm-1 0 2)
(permute-vector perm-1 intvec)
(data intvec))
(cl-array intvec))
(letm ((perm-1 (permutation 4 t))) ;inversions
(set-identity perm-1)
(swap-elements perm-1 1 3)
......@@ -309,7 +309,6 @@
(canonical-cycles perm-1)))
|#
#|
(LISP-UNIT:DEFINE-TEST PERMUTATION
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST 2)
......@@ -322,14 +321,14 @@
(MULTIPLE-VALUE-LIST
(LETM ((PERM-1 (PERMUTATION 4 T)))
(SET-IDENTITY PERM-1)
(DATA PERM-1))))
(CL-ARRAY PERM-1))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST #(3 2 1 0))
(MULTIPLE-VALUE-LIST
(LETM ((PERM-1 (PERMUTATION 4 T)))
(SET-IDENTITY
PERM-1)
(DATA (PERMUTATION-REVERSE PERM-1)))))
(CL-ARRAY (PERMUTATION-REVERSE PERM-1)))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST #(0 3 1 2))
(MULTIPLE-VALUE-LIST
......@@ -340,25 +339,25 @@
(PERMUTATION-NEXT PERM-1)
(PERMUTATION-NEXT PERM-1)
(PERMUTATION-INVERSE PERM-2 PERM-1)
(DATA PERM-2))))
(CL-ARRAY PERM-2))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST #(0 3 2 1))
(MULTIPLE-VALUE-LIST
(LETM ((PERM-1 (PERMUTATION 4 T)))
(SET-IDENTITY PERM-1)
(SWAP-ELEMENTS PERM-1 1 3)
(DATA PERM-1))))
(CL-ARRAY PERM-1))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST #(33 44 11 22))
(MULTIPLE-VALUE-LIST
(LETM ((PERM-1 (PERMUTATION 4 T))
(INTVEC (VECTOR-FIXNUM
#(11 22 33 44))))
(INTVEC (VECTOR-SIGNED-BYTE-32
(A 11 22 33 44))))
(SET-IDENTITY PERM-1)
(SWAP-ELEMENTS PERM-1 1 3)
(SWAP-ELEMENTS PERM-1 0 2)
(PERMUTE-VECTOR PERM-1 INTVEC)
(DATA INTVEC))))
(CL-ARRAY INTVEC))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST 3)
(MULTIPLE-VALUE-LIST
......@@ -381,5 +380,4 @@
(SWAP-ELEMENTS PERM-1 1 3)
(SWAP-ELEMENTS PERM-1 0 2)
(CANONICAL-CYCLES PERM-1)))))
|#
......@@ -145,6 +145,16 @@ will be visible; however, the function should not be used outside a
the argument in the letm binding.
</p>
<h3>Additional definitions</h3>
Some definitions are provided because of their usefulness, even though
GSL doesn't have them.
<ul>
<li><code>invert-matrix</code> finds the inverse of a matrix and uses
GSL's LU decomposition functions.</li>
<li>IEEE floating point number analysis.</li>
</ul>
<h3>Status</h3>
<div class="content">
Consistent with the <a href="development.html">development</a>
......@@ -190,7 +200,7 @@ gamma-randist, negative-binomial.
<address><a href="mailto:gsll-devel@common-lisp.net">Liam Healy</a></address>
<!-- hhmts start -->
<small>
Time-stamp: <2008-08-31 18:40:51EDT documentation.html>
Time-stamp: <2008-09-21 15:37:13EDT documentation.html>
</small>
<!-- hhmts end -->
</div>
......
;; LU decomposition
;; Liam Healy, Thu Apr 27 2006 - 12:42
;; Time-stamp: <2008-08-11 23:10:56EDT lu.lisp>
;; Time-stamp: <2008-09-21 15:25:09EDT lu.lisp>
;; $Id$
(in-package :gsl)
......@@ -133,6 +133,7 @@
;;; Examples and unit test
(export 'invert-matrix)
(defun invert-matrix (mat)
"Invert the matrix."
(letm ((mmat (matrix-double-float mat))
......@@ -149,3 +150,12 @@
(make-array* '(2 2) 'double-float :initial-contents '(1.0d0 2.0d0 3.0d0 4.0d0))))
|#
(LISP-UNIT:DEFINE-TEST LU
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST
#2A((-1.9999999999999998 1.0)
(1.4999999999999998 -0.49999999999999994)))
(MULTIPLE-VALUE-LIST
(INVERT-MATRIX
(MAKE-ARRAY* '(2 2) 'DOUBLE-FLOAT :INITIAL-CONTENTS
'(1.0 2.0 3.0 4.0))))))
;; Sorting
;; Liam Healy, Fri Apr 14 2006 - 20:20
;; Time-stamp: <2008-08-09 18:34:29EDT sorting.lisp>
;; Time-stamp: <2008-09-20 22:29:33EDT sorting.lisp>
;; $Id$
(in-package :gsl)
......@@ -144,8 +144,7 @@
"Find the smallest elements of the vector v and put them into dest,
which must be shorter than v.")
(defmfun sort-vector-smallest-index
(combination (v vector))
(defmfun sort-vector-smallest-index (combination (v vector))
("gsl_sort_vector" :type "_smallest_index")
(((c-pointer combination) :pointer) ((total-size combination) sizet)
((mpointer v) :pointer)
......@@ -246,69 +245,79 @@
#|
(make-tests sorting
(letm ((vec (vector-double-float #(7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0))))
(letm ((vec (vector-double-float (a 7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0))))
(sort-vector vec)
(data vec))
(cl-array vec))
(letm ((perm (permutation 5))
(vec (vector-double-float #(7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0))))
(vec (vector-double-float (a 7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0))))
(sort-vector-index perm vec)
(data perm))
(letm ((vec (vector-double-float #(7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0)))
(cl-array perm))
(letm ((vec (vector-double-float (a 7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0)))
(smallest (vector-double-float 3)))
(sort-vector-smallest smallest vec)
(data smallest))
(letm ((vec (vector-double-float #(7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0))))
(sort-vector-smallest-index 3 vec))
(cl-array smallest))
(letm ((vec (vector-double-float (a 7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0)))
(comb (combination '(5 3))))
(cl-array (sort-vector-smallest-index comb vec)))
(letm ((vec (vector-double-float (a 7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0)))
(sm (combination '(5 3))))
(sort-smallest-index sm vec))
(letm ((vec (vector-double-float #(7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0)))
(cl-array (sort-smallest-index sm vec)))
(letm ((vec (vector-double-float (a 7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0)))
(largest (vector-double-float 3)))
(sort-vector-largest largest vec)
(data largest))
(letm ((vec (vector-double-float #(7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0))))
(sort-vector-largest-index 3 vec)))
(cl-array largest))
(letm ((vec (vector-double-float (a 7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0)))
(comb (combination '(5 3))))
(cl-array (sort-vector-largest-index comb vec))))
|#
#|
(LISP-UNIT:DEFINE-TEST SORTING
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST #(-3.21d0 -2.0d0 1.0d0 7.1d0 12.8d0))
(LIST #(-3.21 -2.0 1.0 7.1 12.8))
(MULTIPLE-VALUE-LIST
(LETM
((VEC
(VECTOR-DOUBLE-FLOAT
#(7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0))))
(SORT-VECTOR VEC) (DATA VEC))))
(LETM ((VEC (VECTOR-DOUBLE-FLOAT (A 7.1 -2.0 12.8 -3.21 1.0))))
(SORT-VECTOR VEC) (CL-ARRAY VEC))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST #(3 1 4 0 2))
(MULTIPLE-VALUE-LIST
(LETM ((PERM (PERMUTATION 5))
(VEC (VECTOR-DOUBLE-FLOAT #(7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0))))
(VEC (VECTOR-DOUBLE-FLOAT (A 7.1 -2.0 12.8 -3.21 1.0))))
(SORT-VECTOR-INDEX PERM VEC)
(DATA PERM))))
(CL-ARRAY PERM))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST #(-3.21d0 -2.0d0 1.0d0))
(LIST #(-3.21 -2.0 1.0))
(MULTIPLE-VALUE-LIST
(LETM ((VEC (VECTOR-DOUBLE-FLOAT #(7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0)))
(LETM ((VEC (VECTOR-DOUBLE-FLOAT (A 7.1 -2.0 12.8 -3.21 1.0)))
(SMALLEST (VECTOR-DOUBLE-FLOAT 3)))
(SORT-VECTOR-SMALLEST SMALLEST VEC)
(DATA SMALLEST))))
(CL-ARRAY SMALLEST))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST #(3 1 4))
(MULTIPLE-VALUE-LIST
(LETM ((VEC (VECTOR-DOUBLE-FLOAT #(7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0))))
(SORT-VECTOR-SMALLEST-INDEX 3 VEC))))
(LETM
((VEC (VECTOR-DOUBLE-FLOAT
(A 7.1 -2.0 12.8 -3.21 1.0)))
(COMB (COMBINATION '(5 3))))
(CL-ARRAY (SORT-VECTOR-SMALLEST-INDEX COMB VEC)))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST #(3 1 4))
(MULTIPLE-VALUE-LIST
(LETM ((VEC (VECTOR-DOUBLE-FLOAT
(A 7.1 -2.0 12.8 -3.21 1.0)))
(SM (COMBINATION '(5 3))))
(CL-ARRAY (SORT-SMALLEST-INDEX SM VEC)))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST #(12.8d0 7.1d0 1.0d0))
(LIST #(12.8 7.1 1.0))
(MULTIPLE-VALUE-LIST
(LETM ((VEC (VECTOR-DOUBLE-FLOAT #(7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0)))
(LETM ((VEC (VECTOR-DOUBLE-FLOAT (A 7.1 -2.0 12.8 -3.21 1.0)))
(LARGEST (VECTOR-DOUBLE-FLOAT 3)))
(SORT-VECTOR-LARGEST LARGEST VEC) (DATA LARGEST))))
(SORT-VECTOR-LARGEST LARGEST VEC)
(CL-ARRAY LARGEST))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST #(2 0 4))
(MULTIPLE-VALUE-LIST
(LETM ((VEC (VECTOR-DOUBLE-FLOAT #(7.1d0 -2.0d0 12.8d0 -3.21d0 1.0d0))))
(SORT-VECTOR-LARGEST-INDEX 3 VEC)))))
|#
(LETM
((VEC (VECTOR-DOUBLE-FLOAT (A 7.1 -2.0 12.8 -3.21 1.0)))
(COMB (COMBINATION '(5 3))))
(CL-ARRAY (SORT-VECTOR-LARGEST-INDEX COMB VEC))))))
;; Coulumb functions
;; Liam Healy, Sat Mar 18 2006 - 23:23
;; Time-stamp: <2008-09-14 22:29:18EDT coulomb.lisp>
;; Time-stamp: <2008-09-20 22:08:50EDT coulomb.lisp>
;; $Id$
(in-package :gsl)
......@@ -146,7 +146,6 @@
(coulomb-CL-array 0.0d0 1.0d0 cl) (cl-array cl)))
|#
#|
(LISP-UNIT:DEFINE-TEST COULOMB
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST 0.1641699972477976d0 1.8226531089715347d-16)
......@@ -207,5 +206,3 @@
(MULTIPLE-VALUE-LIST
(LETM ((CL (VECTOR-DOUBLE-FLOAT 3)))
(COULOMB-CL-ARRAY 0.0d0 1.0d0 CL) (CL-ARRAY CL)))))
|#
;; Absolute deviation
;; Liam Healy, Sun Dec 31 2006 - 13:19
;; Time-stamp: <2008-08-20 22:14:51EDT absolute-deviation.lisp>
;; Time-stamp: <2008-09-21 15:54:24EDT absolute-deviation.lisp>
;; $Id$
(in-package :gsl)
......@@ -50,23 +50,22 @@
#|
(make-tests absolute-deviation
(letm ((vec (vector-double-float #(-3.21d0 1.0d0 12.8d0)))
(weights (vector-double-float #(3.0d0 1.0d0 2.0d0))))
(letm ((vec (vector-double-float (a -3.21d0 1.0d0 12.8d0)))
(weights (vector-double-float (a 3.0d0 1.0d0 2.0d0))))
(let ((mean (mean vec)))
(list
(absolute-deviation vec)
(weighted-absolute-deviation vec weights)
(absolute-deviation vec mean)))))
|#
(LISP-UNIT:DEFINE-TEST ABSOLUTE-DEVIATION
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST (LIST 6.18d0 6.647777777777779d0 6.18d0))
(MULTIPLE-VALUE-LIST
(LETM ((VEC (VECTOR-DOUBLE-FLOAT #(-3.21d0 1.0d0 12.8d0)))
(WEIGHTS (VECTOR-DOUBLE-FLOAT #(3.0d0 1.0d0 2.0d0))))
(LETM ((VEC (VECTOR-DOUBLE-FLOAT (A -3.21d0 1.0d0 12.8d0)))
(WEIGHTS (VECTOR-DOUBLE-FLOAT (A 3.0d0 1.0d0 2.0d0))))
(LET ((MEAN (MEAN VEC)))
(LIST (ABSOLUTE-DEVIATION VEC)
(WEIGHTED-ABSOLUTE-DEVIATION VEC WEIGHTS)
(ABSOLUTE-DEVIATION VEC MEAN)))))))
|#
;; Autocorrelation
;; Liam Healy, Sun Dec 31 2006 - 13:19
;; Time-stamp: <2008-08-20 22:14:26EDT autocorrelation.lisp>
;; Time-stamp: <2008-09-21 15:56:14EDT autocorrelation.lisp>
;; $Id$
(in-package :gsl)
......@@ -27,20 +27,20 @@
#|
(make-tests autocorrelation
(letm ((vec (vector-double-float #(-3.21d0 1.0d0 12.8d0))))
(letm ((vec (vector-double-float (a -3.21d0 1.0d0 12.8d0))))
(let ((mean (mean vec)))
(list
(autocorrelation vec)
(autocorrelation vec mean)))))
|#
(LISP-UNIT:DEFINE-TEST AUTOCORRELATION
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST
(LIST -0.04646366834251103d0 -0.04646366834251103d0))
(MULTIPLE-VALUE-LIST
(LETM ((VEC (VECTOR-DOUBLE-FLOAT #(-3.21d0 1.0d0 12.8d0))))
(LETM ((VEC (VECTOR-DOUBLE-FLOAT (A -3.21d0 1.0d0 12.8d0))))
(LET ((MEAN (MEAN VEC)))
(LIST (AUTOCORRELATION VEC)
(AUTOCORRELATION VEC MEAN)))))))
|#
;; Covariance
;; Liam Healy, Sun Dec 31 2006 - 13:19
;; Time-stamp: <2008-08-20 22:13:48EDT covariance.lisp>
;; Time-stamp: <2008-09-21 15:57:06EDT covariance.lisp>
;; $Id$
(in-package :gsl)
......@@ -30,13 +30,14 @@
#|
(make-tests covariance
(letm ((vec1 (vector-double-float #(-3.21d0 1.0d0 12.8d0)))
(vec2 (vector-double-float #(1.15d0 -1.0d0 0.5d0))))
(letm ((vec1 (vector-double-float (a -3.21d0 1.0d0 12.8d0)))
(vec2 (vector-double-float (a 1.15d0 -1.0d0 0.5d0))))
(let ((mean1 (mean vec1))
(mean2 (mean vec2)))
(list
(covariance vec1 vec2)
(covariance vec1 vec2 mean1 mean2)))))
|#
(LISP-UNIT:DEFINE-TEST COVARIANCE
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
......@@ -44,9 +45,8 @@
(LIST -0.2929999999999998d0 -0.2929999999999998d0))
(MULTIPLE-VALUE-LIST
(LETM
((VEC1 (VECTOR-DOUBLE-FLOAT #(-3.21d0 1.0d0 12.8d0)))
(VEC2 (VECTOR-DOUBLE-FLOAT #(1.15d0 -1.0d0 0.5d0))))
((VEC1 (VECTOR-DOUBLE-FLOAT (a -3.21d0 1.0d0 12.8d0)))
(VEC2 (VECTOR-DOUBLE-FLOAT (a 1.15d0 -1.0d0 0.5d0))))
(LET ((MEAN1 (MEAN VEC1)) (MEAN2 (MEAN VEC2)))
(LIST (COVARIANCE VEC1 VEC2)
(COVARIANCE VEC1 VEC2 MEAN1 MEAN2)))))))
|#
;; Skewness and kurtosis.
;; Liam Healy, Sun Dec 31 2006 - 14:20
;; Time-stamp: <2008-08-20 22:14:37EDT higher-moments.lisp>
;; Time-stamp: <2008-09-21 15:55:21EDT higher-moments.lisp>
;; $Id$
(in-package :gsl)
......@@ -82,7 +82,7 @@
#|
(make-tests higher-moments
(letm ((vec (vector-double-float #(-3.21d0 1.0d0 12.8d0))))
(letm ((vec (vector-double-float (a -3.21d0 1.0d0 12.8d0))))
(let* ((mean (mean vec))
(sd (standard-deviation vec mean)))
(list
......@@ -90,6 +90,7 @@
(skewness vec mean sd)
(kurtosis vec)
(kurtosis vec mean sd)))))
|#
(LISP-UNIT:DEFINE-TEST HIGHER-MOMENTS
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
......@@ -97,10 +98,9 @@
(LIST 0.2765118983985497d0 0.2765118983985497d0
-2.333333333333333d0 -2.333333333333333d0))
(MULTIPLE-VALUE-LIST
(LETM ((VEC (VECTOR-DOUBLE-FLOAT #(-3.21d0 1.0d0 12.8d0))))
(LETM ((VEC (VECTOR-DOUBLE-FLOAT (A -3.21d0 1.0d0 12.8d0))))
(LET* ((MEAN (MEAN VEC))
(SD (STANDARD-DEVIATION VEC MEAN)))
(LIST (SKEWNESS VEC) (SKEWNESS VEC MEAN SD)
(KURTOSIS VEC)
(KURTOSIS VEC MEAN SD)))))))
|#
;; Mean, standard deviation, and variance
;; Liam Healy, Sat Dec 2 2006 - 22:15
;; Time-stamp: <2008-08-17 19:00:54EDT mean-variance.lisp>
;; Time-stamp: <2008-09-21 15:52:16EDT mean-variance.lisp>
;; $Id$
(in-package :gsl)
......@@ -188,30 +188,31 @@
#|
(make-tests mean-variance
(letm ((vec (vector-double-float #(-3.21d0 1.0d0 12.8d0)))
(weights (vector-double-float #(3.0d0 1.0d0 2.0d0))))
(let ((mean (mean vec))
(wmean (weighted-mean vec weights)))
(list
mean wmean
(variance vec)
(variance vec mean)
(weighted-variance vec weights)
(weighted-variance vec weights wmean)
(standard-deviation vec)
(standard-deviation vec mean)
(variance-with-fixed-mean vec 4.0d0)
(standard-deviation-with-fixed-mean vec 4.0d0))))
(letm ((vec (vector-fixnum #(8 4 -2))))
(let ((mean (mean vec)))
(list
mean
(variance vec)
(variance vec mean)
(standard-deviation vec)
(standard-deviation vec mean)
(variance-with-fixed-mean vec 4.0d0)
(standard-deviation-with-fixed-mean vec 4.0d0)))))
(letm ((vec (vector-double-float (a -3.21d0 1.0d0 12.8d0)))
(weights (vector-double-float (a 3.0d0 1.0d0 2.0d0))))
(let ((mean (mean vec))
(wmean (weighted-mean vec weights)))
(list
mean wmean
(variance vec)
(variance vec mean)
(weighted-variance vec weights)
(weighted-variance vec weights wmean)
(standard-deviation vec)
(standard-deviation vec mean)
(variance-with-fixed-mean vec 4.0d0)
(standard-deviation-with-fixed-mean vec 4.0d0))))
(letm ((vec (vector-signed-byte-32 (a 8 4 -2))))
(let ((mean (mean vec)))
(list
mean
(variance vec)
(variance vec mean)
(standard-deviation vec)
(standard-deviation vec mean)
(variance-with-fixed-mean vec 4.0d0)
(standard-deviation-with-fixed-mean vec 4.0d0)))))
|#
(LISP-UNIT:DEFINE-TEST MEAN-VARIANCE
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
......@@ -223,8 +224,8 @@
46.14136666666667d0 6.792743677385941d0))
(MULTIPLE-VALUE-LIST
(LETM
((VEC (VECTOR-DOUBLE-FLOAT #(-3.21d0 1.0d0 12.8d0)))
(WEIGHTS (VECTOR-DOUBLE-FLOAT #(3.0d0 1.0d0 2.0d0))))
((VEC (VECTOR-DOUBLE-FLOAT (A -3.21d0 1.0d0 12.8d0)))
(WEIGHTS (VECTOR-DOUBLE-FLOAT (A 3.0d0 1.0d0 2.0d0))))
(LET ((MEAN (MEAN VEC))
(WMEAN (WEIGHTED-MEAN VEC WEIGHTS)))
(LIST MEAN WMEAN (VARIANCE VEC) (VARIANCE VEC MEAN)
......@@ -242,7 +243,7 @@
5.033222956847167d0 17.333333333333332d0
4.163331998932265d0))
(MULTIPLE-VALUE-LIST
(LETM ((VEC (VECTOR-FIXNUM #(8 4 -2))))
(LETM ((VEC (VECTOR-SIGNED-BYTE-32 (A 8 4 -2))))
(LET ((MEAN (MEAN VEC)))
(LIST MEAN (VARIANCE VEC) (VARIANCE VEC MEAN)
(STANDARD-DEVIATION VEC)
......@@ -250,4 +251,3 @@
(VARIANCE-WITH-FIXED-MEAN VEC 4.0d0)
(STANDARD-DEVIATION-WITH-FIXED-MEAN VEC
4.0d0)))))))
|#
;; Median and percentile
;; Liam Healy, Sun Dec 31 2006 - 13:19
;; Time-stamp: <2008-08-20 22:35:08EDT median-percentile.lisp>
;; Time-stamp: <2008-09-21 15:58:10EDT median-percentile.lisp>
;; $Id$
(in-package :gsl)
......@@ -54,22 +54,22 @@
#|
(make-tests median-percentile
(letm ((vec (vector-double-float #(-3.21d0 1.0d0 12.8d0))))
(letm ((vec (vector-double-float (a -3.21d0 1.0d0 12.8d0))))
(median vec))
(letm ((vec (vector-double-float
#(-18.0d0 -12.0d0 -3.21d0 0.5d0 1.0d0 2.7d0 12.8d0))))
(a -18.0d0 -12.0d0 -3.21d0 0.5d0 1.0d0 2.7d0 12.8d0))))
(quantile vec 0.75d0)))
|#
(LISP-UNIT:DEFINE-TEST MEDIAN-PERCENTILE
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST 1.0d0)
(MULTIPLE-VALUE-LIST
(LETM ((VEC (VECTOR-DOUBLE-FLOAT #(-3.21d0 1.0d0 12.8d0))))
(LETM ((VEC (VECTOR-DOUBLE-FLOAT (A -3.21d0 1.0d0 12.8d0))))
(MEDIAN VEC))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST 1.85d0)
(MULTIPLE-VALUE-LIST
(LETM ((VEC (VECTOR-DOUBLE-FLOAT
#(-18.0d0 -12.0d0 -3.21d0 0.5d0 1.0d0 2.7d0 12.8d0))))
(A -18.0d0 -12.0d0 -3.21d0 0.5d0 1.0d0 2.7d0 12.8d0))))
(QUANTILE VEC 0.75d0)))))
|#
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment