Skip to content

Commit

Permalink
Merge pull request #636 from pazeshun/lmeds-doc
Browse files Browse the repository at this point in the history
Add documentation of lmeds functions
  • Loading branch information
k-okada authored Nov 9, 2023
2 parents be03803 + 223c945 commit 69be3cf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions irteus/irtmath.l
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@
;; lmeds
;;http://www-pse.cheme.kyoto-u.ac.jp/~kano/document/text-PCA.pdf
(defun lms (point-list)
"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"
(let ((v^ (vector-mean point-list))
(point-length (length point-list))
delx x v eigen-res eigen-val eigen-vec min-lam min-vec)
Expand All @@ -543,10 +544,12 @@
))

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

(defun lms-error (result point-list)
"returns the mean of the square of the distance from the fitted line/plane/hyperplane to each point in point-list"
(let ((ret-err 0) tmp-err)
(dolist (l point-list)
(setq tmp-err (lms-estimate result l))
Expand All @@ -555,13 +558,14 @@
(/ ret-err (length point-list))
))

;; choose num points randomly and apply lms to find the souliton with smallest errors
;; to use ransac ransac
;; choose num points randomly and apply lms to find the solution with the smallest error
;; to use ransac
;; :lmeds-error-func -> set to ransac-error
;; :ransac-threshold err^2 (square of the distance from the plane)
(defun lmeds (point-list &key (num 5) (err-rate 0.3) (iteration) (ransac-threshold)
(lms-func #'lms) (lmeds-error-func #'lmeds-error)
(lms-estimate-func #'lms-estimate))
"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"
(let (point-num r result result-list error-list iter
comb-index comb-index-list point-list-tmp)
;; initialize variables
Expand Down Expand Up @@ -599,6 +603,7 @@
))

(defun lmeds-error (result point-list &key (lms-estimate-func #'lms-estimate))
"returns the median of the square of the distance from the fitted line/plane/hyperplane to each point in point-list"
(let (tmp-err err)
(dolist (l point-list)
(setq tmp-err (funcall lms-estimate-func result l))
Expand All @@ -608,6 +613,7 @@
))

(defun lmeds-error-mat (result mat &key (lms-estimate-func #'lms-estimate))
"matrixed version of lmeds-error. mat is the matrixed version of point-list"
(let ((size (array-dimension mat 0))
(p (float-vector 0 0 0))
tmp-err err)
Expand Down

1 comment on commit 69be3cf

@k-okada
Copy link
Member Author

@k-okada k-okada commented on 69be3cf Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing jskeus documentation

Please check latest documents before merging

PDF version of Japanese jmanual: jmanual.pdf
HTML version of Japanese manual: jmanual.html
Sphinx (ReST) version of Japanese manual: jmanual.rst

Please sign in to comment.