diff options
| author | Elizabeth Alexander Hunt <me@liz.coffee> | 2026-07-02 11:55:17 -0700 |
|---|---|---|
| committer | Elizabeth Alexander Hunt <me@liz.coffee> | 2026-07-02 11:55:17 -0700 |
| commit | 6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6 (patch) | |
| tree | ed97e39ec77c5231ffd2c394493e68d00ddac5a4 /Homework/math4610/deprecated-cl/vector,least-squares.lisp | |
| download | misc-undergrad-6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6.tar.gz misc-undergrad-6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6.zip | |
Diffstat (limited to 'Homework/math4610/deprecated-cl/vector,least-squares.lisp')
| -rw-r--r-- | Homework/math4610/deprecated-cl/vector,least-squares.lisp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Homework/math4610/deprecated-cl/vector,least-squares.lisp b/Homework/math4610/deprecated-cl/vector,least-squares.lisp new file mode 100644 index 0000000..687af32 --- /dev/null +++ b/Homework/math4610/deprecated-cl/vector,least-squares.lisp @@ -0,0 +1,14 @@ +(in-package :lizfcm.vector) + +(defun least-squares-reg (x y) + (let* ((n (length x)) + (sum-y (reduce #'+ y)) + (sum-x (reduce #'+ x)) + (sum-xy (reduce #'+ (mapcar #'* x y))) + (sum-xsquared (reduce #'+ (mapcar #'* x x))) + (b (/ (- (* sum-y sum-xsquared) (* sum-x sum-xy)) + (- (* n sum-xsquared) (* sum-x sum-x)))) + (a (/ (- (* n sum-xy) (* sum-x sum-y)) + (- (* n sum-xsquared) (* sum-x sum-x))))) + (list a b))) + |
