2 ;;; Copyright (c) 2007, by A.J. Rossini <blindglobe@gmail.com>
3 ;;; See COPYRIGHT file for any additional restrictions (BSD license).
4 ;;; Since 1991, ANSI was finally finished. Edited for ANSI Common Lisp.
6 ;;; This is semi-external to lispstat core packages. The dependency
7 ;;; should be that lispstat packages are dependencies for the unit
8 ;;; tests. However, where they will end up is still to be
11 (in-package :lisp-stat-unittests
)
15 (deftestsuite lisp-stat-ut-probdistn
(lisp-stat-ut) ())
17 ;;; Probability distributions
19 ;; This macro should be generalized, but it's a good start now.
20 ;;(defmacro ProbDistnTests (prefixName
21 ;; quant-params quant-answer
22 ;; cdf-params cdf-answer
23 ;; pmf-params pmf-answer
24 ;; rand-params rand-answer)
25 ;; (deftestsuite lisp-stat-ut-probdist-,prefixName (lisp-stat-ut-probdistn)
27 ;; (:documentation "testing for ,testName distribution results")
28 ;; (:test (ensure-same
29 ;; (lisp-stat-ut-basics:,testName-quant ,quant-params) ,quant-answer))
30 ;; (:test (ensure-same
31 ;; (lisp-stat-ut-basics:,testName-cdf ,cdf-params) ,cdf-answer))
32 ;; (:test (ensure-same
33 ;; (lisp-stat-ut-basics:,testName-pmf ,pmf-params) ,pmf-answer))
37 ;; (lisp-stat-ut-basics:,testName-rand ,rand-params) ,rand-answer)))))
39 ;;; Normal distribution
41 (deftestsuite lisp-stat-ut-probdist-f
(lisp-stat-ut-probdistn)
43 (:documentation
"testing for Gaussian distn results")
55 (list -
0.40502015f0 -
0.8091404f0
)))
57 (bivnorm-cdf 0.2 0.4 0.6)
60 ;;;; Cauchy distribution
62 (deftestsuite lisp-stat-ut-probdist-cauchy
(lisp-stat-ut-probdistn)
64 (:documentation
"testing for Cachy-distn results")
76 (list -
1.06224644160405 -
0.4524695943939537))))
78 ;;;; Gamma distribution
80 (deftestsuite lisp-stat-ut-probdist-gamma
(lisp-stat-ut-probdistn)
82 (:documentation
"testing for gamma distn results")
84 (gamma-quant 0.95 4.3)
88 0.028895150986674906))
94 (list 2.454918912880936 4.081365384357454))))
96 ;;;; Chi-square distribution
98 (deftestsuite lisp-stat-ut-probdist-chisq
(lisp-stat-ut-probdistn)
100 (:documentation
"testing for Chi-square distn results")
106 0.03743422675631789))
109 0.08065690818083521))
114 (list 1.968535826180572 2.9988646156942997)))))
116 ;;;; Beta distribution
118 (deftestsuite lisp-stat-ut-probdist-beta
(lisp-stat-ut-probdistn)
120 (:documentation
"testing for beta distn results")
122 (beta-quant 0.95 3 2)
126 0.4247997418541529 ))
128 (beta-dens 0.4 2 2.4)
129 1.5964741858913518 ))
132 (list 0.8014897077282279 0.6516371997922659))))
136 (deftestsuite lisp-stat-ut-probdist-t
(lisp-stat-ut-probdistn)
138 (:documentation
"testing for t-distn results")
150 (list -
0.34303672776089306 -
1.142505872436518))))
154 (deftestsuite lisp-stat-ut-probdist-f
(lisp-stat-ut-probdistn)
156 (:documentation
"testing for f-distn results")
158 (f-quant 0.95 3 5) 5.409451318117459))
164 0.37551128864591415))
169 (list 0.7939093442091963 0.07442694152491144)))))
171 ;;;; Poisson distribution
173 (deftestsuite lisp-stat-ut-probdist-poisson
(lisp-stat-ut-probdistn)
175 (:documentation
"testing for poisson distribution results")
177 (poisson-quant 0.95 3.2) 6))
180 0.17120125672252395))
183 0.13043905274097067))
190 ;; Binomial distribution
192 (deftestsuite lisp-stat-ut-probdist-binomial
(lisp-stat-ut-probdistn)
194 (:documentation
"testing for binomial distribution results")
197 (binomial-quant 0.95 3 0.4) ;;; DOESN'T RETURN
200 (binomial-quant 0 3 0.4)
204 (binomial-cdf 1 3 0.4)
208 (binomial-pmf 1 3 0.4)
213 (binomial-rand 5 3 0.4)