comparison scripts/deprecated/mahalanobis.m @ 22214:0ff3bd7d2750

mahalanobis: alternative for performance improvement (bug #45877)
author Lachlan Andrew <lachlanbis@gmail.com>
date Sat, 06 Aug 2016 23:47:20 +0100
parents 516bb87ea72e
children bac0d6f07a3e
comparison
equal deleted inserted replaced
22213:1723063e65f3 22214:0ff3bd7d2750
74 x = bsxfun (@minus, x, xm); 74 x = bsxfun (@minus, x, xm);
75 y = bsxfun (@minus, y, ym); 75 y = bsxfun (@minus, y, ym);
76 76
77 w = (x' * x + y' * y) / (xr + yr - 2); 77 w = (x' * x + y' * y) / (xr + yr - 2);
78 78
79 winv = inv (w); 79 retval = sumsq ((xm - ym) / chol (w));
80
81 retval = (xm - ym) * winv * (xm - ym)';
82 80
83 endfunction 81 endfunction
84
85 82
86 ## Test input validation 83 ## Test input validation
87 %!error mahalanobis () 84 %!error mahalanobis ()
88 %!error mahalanobis (1, 2, 3) 85 %!error mahalanobis (1, 2, 3)
89 %!error mahalanobis ('A', 'B') 86 %!error mahalanobis ('A', 'B')