From 834bb45be7e74553f51da00bad95595666586a7c Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Tue, 10 Oct 2023 14:44:33 -0600 Subject: problem one hw 4 --- src/tests,vector.lisp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/tests,vector.lisp') 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 -- cgit v1.3