Skip to content

Commit 69be3cf

Browse files
authored
Merge pull request #636 from pazeshun/lmeds-doc
Add documentation of lmeds functions
2 parents be03803 + 223c945 commit 69be3cf

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

irteus/irtmath.l

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@
523523
;; lmeds
524524
;;http://www-pse.cheme.kyoto-u.ac.jp/~kano/document/text-PCA.pdf
525525
(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"
526527
(let ((v^ (vector-mean point-list))
527528
(point-length (length point-list))
528529
delx x v eigen-res eigen-val eigen-vec min-lam min-vec)
@@ -543,10 +544,12 @@
543544
))
544545

545546
(defun lms-estimate (res point-)
547+
"returns the signed distance from the fitted line/plane/hyperplane to point-"
546548
(+ (v. point- (car res)) (cadr res))
547549
)
548550

549551
(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"
550553
(let ((ret-err 0) tmp-err)
551554
(dolist (l point-list)
552555
(setq tmp-err (lms-estimate result l))
@@ -555,13 +558,14 @@
555558
(/ ret-err (length point-list))
556559
))
557560

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
560563
;; :lmeds-error-func -> set to ransac-error
561564
;; :ransac-threshold err^2 (square of the distance from the plane)
562565
(defun lmeds (point-list &key (num 5) (err-rate 0.3) (iteration) (ransac-threshold)
563566
(lms-func #'lms) (lmeds-error-func #'lmeds-error)
564567
(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"
565569
(let (point-num r result result-list error-list iter
566570
comb-index comb-index-list point-list-tmp)
567571
;; initialize variables
@@ -599,6 +603,7 @@
599603
))
600604

601605
(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"
602607
(let (tmp-err err)
603608
(dolist (l point-list)
604609
(setq tmp-err (funcall lms-estimate-func result l))
@@ -608,6 +613,7 @@
608613
))
609614

610615
(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"
611617
(let ((size (array-dimension mat 0))
612618
(p (float-vector 0 0 0))
613619
tmp-err err)

0 commit comments

Comments
 (0)