diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-10-10 14:44:33 -0600 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-10-10 14:44:33 -0600 |
commit | 834bb45be7e74553f51da00bad95595666586a7c (patch) | |
tree | 607a75849b4096711c6c61df580d542e3c92ffd8 /src/tests,vector.lisp | |
parent | e46e5eee74af75aa1123b2370ff2f4587f4adc2a (diff) | |
download | cmath-834bb45be7e74553f51da00bad95595666586a7c.tar.gz cmath-834bb45be7e74553f51da00bad95595666586a7c.zip |
problem one hw 4
Diffstat (limited to 'src/tests,vector.lisp')
-rw-r--r-- | src/tests,vector.lisp | 11 |
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 |