|
523 | 523 | ;; lmeds
|
524 | 524 | ;;http://www-pse.cheme.kyoto-u.ac.jp/~kano/document/text-PCA.pdf
|
525 | 525 | (defun lms (point-list)
|
| 526 | + "returns the result of line/plane/hyperplane fitting (regression) on point-list with least squares. The result consists of the normal vector and the signed distance to the origin" |
526 | 527 | (let ((v^ (vector-mean point-list))
|
527 | 528 | (point-length (length point-list))
|
528 | 529 | delx x v eigen-res eigen-val eigen-vec min-lam min-vec)
|
|
543 | 544 | ))
|
544 | 545 |
|
545 | 546 | (defun lms-estimate (res point-)
|
| 547 | + "returns the signed distance from the fitted line/plane/hyperplane to point-" |
546 | 548 | (+ (v. point- (car res)) (cadr res))
|
547 | 549 | )
|
548 | 550 |
|
549 | 551 | (defun lms-error (result point-list)
|
| 552 | + "returns the mean of the square of the distance from the fitted line/plane/hyperplane to each point in point-list" |
550 | 553 | (let ((ret-err 0) tmp-err)
|
551 | 554 | (dolist (l point-list)
|
552 | 555 | (setq tmp-err (lms-estimate result l))
|
|
555 | 558 | (/ ret-err (length point-list))
|
556 | 559 | ))
|
557 | 560 |
|
558 |
| -;; choose num points randomly and apply lms to find the souliton with smallest errors |
559 |
| -;; to use ransac ransac |
| 561 | +;; choose num points randomly and apply lms to find the solution with the smallest error |
| 562 | +;; to use ransac |
560 | 563 | ;; :lmeds-error-func -> set to ransac-error
|
561 | 564 | ;; :ransac-threshold err^2 (square of the distance from the plane)
|
562 | 565 | (defun lmeds (point-list &key (num 5) (err-rate 0.3) (iteration) (ransac-threshold)
|
563 | 566 | (lms-func #'lms) (lmeds-error-func #'lmeds-error)
|
564 | 567 | (lms-estimate-func #'lms-estimate))
|
| 568 | + "returns the result of line/plane/hyperplane fitting (regression) on point-list with LMedS. The result consists of the normal vector and the signed distance to the origin" |
565 | 569 | (let (point-num r result result-list error-list iter
|
566 | 570 | comb-index comb-index-list point-list-tmp)
|
567 | 571 | ;; initialize variables
|
|
599 | 603 | ))
|
600 | 604 |
|
601 | 605 | (defun lmeds-error (result point-list &key (lms-estimate-func #'lms-estimate))
|
| 606 | + "returns the median of the square of the distance from the fitted line/plane/hyperplane to each point in point-list" |
602 | 607 | (let (tmp-err err)
|
603 | 608 | (dolist (l point-list)
|
604 | 609 | (setq tmp-err (funcall lms-estimate-func result l))
|
|
608 | 613 | ))
|
609 | 614 |
|
610 | 615 | (defun lmeds-error-mat (result mat &key (lms-estimate-func #'lms-estimate))
|
| 616 | + "matrixed version of lmeds-error. mat is the matrixed version of point-list" |
611 | 617 | (let ((size (array-dimension mat 0))
|
612 | 618 | (p (float-vector 0 0 0))
|
613 | 619 | tmp-err err)
|
|
0 commit comments