summaryrefslogtreecommitdiff
path: root/src/tests,vector.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests,vector.lisp')
-rw-r--r--src/tests,vector.lisp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/tests,vector.lisp b/src/tests,vector.lisp
index 3ffe5a8..6edb1ac 100644
--- a/src/tests,vector.lisp
+++ b/src/tests,vector.lisp
@@ -29,3 +29,14 @@
dist
0.00001))))
+(test least-squares
+ :description "least squares is correct enough"
+ (let ((x '(0 1 2 3 4))
+ (y '(1 2 3 4 5)))
+ (destructuring-bind (m b) (lizfcm.vector:least-squares-reg x y)
+ (is (within-range-p m 1 0.00001))
+ (is (within-range-p b 1 0.00001))))
+ (let ((x '(1 2 3 4 5 6 7))
+ (y '(0.5 3 2 3.5 5 6 7.5)))
+ (destructuring-bind (m b) (lizfcm.vector:least-squares-reg x y)
+ (is (within-range-p m 1 0.3))))) ;; just a guestimate for best fit