Commit a944009d authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Define variable for PDF test iteration count

parent 9f12e41e
;; Emulate the GSL tests for random distributions.
;; Liam Healy 2010-04-17 09:44:49EDT tests.lisp
;; Time-stamp: <2010-05-24 20:38:47EDT tests.lisp>
;; Time-stamp: <2010-06-02 10:05:02EDT tests.lisp>
;;
;; Copyright 2010 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -77,6 +77,7 @@
;; (x (+ +gslt-lower-limit+ (* i +gslt-bin-size+)))
(if retval (warn "observed vs. expected")))))
(defvar *pdf-number-of-tries* 50)
(defun testpdf (pdf-function &rest distribution)
"Test the probability density function in the same way that GSL does.
If everything is functioning correctly, this will return T."
......@@ -84,10 +85,10 @@
(edge (make-array +gslt-BINS+ :element-type 'fixnum :initial-element 0))
(number-of-samples +initial-number-of-samples+)
(cdf (distribution-bin-integral pdf-function)))
(dotimes (i 50)
(dotimes (i *pdf-number-of-tries*)
(let ((mean (apply 'bin-samples count edge number-of-samples distribution)))
(unless (finitep mean) (error "mean ~a is not finite" mean))
(if (limits-check count number-of-samples cdf (< (1+ i) 50))
(if (limits-check count number-of-samples cdf (< (1+ i) *pdf-number-of-tries*))
(if (plusp i) (setf number-of-samples (* 2 number-of-samples)))
(return t))))))
......@@ -35,12 +35,14 @@
(MULTIPLE-VALUE-LIST
(EXPONENTIAL-PDF
0.0d0 10.0d0)))
;; From cdf/test.c test_exponential
(ASSERT-TO-TOLERANCE (EXPONENTIAL-P 0.1d0 0.7d0) 0.13312210024981838d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPONENTIAL-P 1.d-32 0.7d0) 1.4285714285714287d-32 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPONENTIAL-P 1000.0d0 0.7d0) 1.0d0 +TEST-TOL6+)
(ASSERT-TO-TOLERANCE (EXPONENTIAL-Q 0.1d0 0.7d0) 0.8668778997501816d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPONENTIAL-Q 1.d-32 0.7d0) 1.0d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPONENTIAL-Q 1000.0d0 0.7d0) 0.0d0 +TEST-TOL6+)
;; From cdf/test.c test_exponentialinv
(ASSERT-TO-TOLERANCE (EXPONENTIAL-PINV 0.13d0 0.7d0) 0.09748344713345536d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPONENTIAL-PINV 1.42d-32 0.7d0) 9.94d-33 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPONENTIAL-QINV 0.86d0 0.7d0) 0.10557602281420854d0 +TEST-TOL0+)
......
Supports Markdown
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