From: Baris Yenidunya on 29 Aug 2008 12:50 Hi, I'm trying to understand how mahal function in MATLAB works. I see that the method used is different than the MD calculations in the literature. How is QR decomposition used here? Any help (maybe references, links etc.) will be appreciated. Thanks, Baris Yenidunya
From: Peter Perkins on 2 Sep 2008 13:49 Baris Yenidunya wrote: > Hi, > > I'm trying to understand how mahal function in MATLAB works. > I see that the method used is different than the MD > calculations in the literature. How is QR decomposition used > here? Any help (maybe references, links etc.) will be > appreciated. Baris, presumably by "in the literature", you mean formulas like the one that appears in the help for MAHAL. That's fine for understanding what the Mahalanobis distance is, but not so good for computational purposes. MAHAL rewrites that explicit inversion of the cov matrix as a solution of a linear system, by noticing that the (squared) Mahalanobis distance can be expressed as D = Y0*S^(-1)*Y0' = Y0*(X0'*X0)^(-1)*Y0' = Y0*((Q*R)'*(Q*R))^(-1)*Y0' = Y0*(R'*R)^(-1)*Y0' = Y0*R^(-1) * (Y0*R^(-1))' and then noticing that you can do that using MATLAB's backslash operator. Hope this helps.
From: Baris Yenidunya on 3 Sep 2008 14:35 Well it really does, thanks a lot Peter Baris Yenidunya
From: Dilber Ayhan on 14 Sep 2008 11:15 Mr. Perkins, after your explanation to my friend Barış, I wonder that in the matlab function of mahal, Why the equation is multiplied with (rx-1)? I did not find where it comes. the equation; ri = R'\(Y-M)'; d = sum(ri.*ri,1)'*(rx-1); I think sum(ri.*ri,1)' is just Y0*R^(-1) * (Y0*R^(-1))' but what about (rx-1)? thanks dilber ayhan Peter Perkins <Peter.PerkinsRemoveThis(a)mathworks.com> wrote in message <g9jubp$pkv$1(a)fred.mathworks.com>... > Baris Yenidunya wrote: > > Hi, > > > > I'm trying to understand how mahal function in MATLAB works. > > I see that the method used is different than the MD > > calculations in the literature. How is QR decomposition used > > here? Any help (maybe references, links etc.) will be > > appreciated. > > Baris, presumably by "in the literature", you mean formulas like the one that appears in the help for MAHAL. That's fine for understanding what the Mahalanobis distance is, but not so good for computational purposes. MAHAL rewrites that explicit inversion of the cov matrix as a solution of a linear system, by noticing that the (squared) Mahalanobis distance can be expressed as > > D = Y0*S^(-1)*Y0' > = Y0*(X0'*X0)^(-1)*Y0' > = Y0*((Q*R)'*(Q*R))^(-1)*Y0' > = Y0*(R'*R)^(-1)*Y0' > = Y0*R^(-1) * (Y0*R^(-1))' > > and then noticing that you can do that using MATLAB's backslash operator. > > Hope this helps.
From: Dilber Ayhan on 14 Sep 2008 15:38 Hi, as a second question, is multicollinearity prevented by using QR decomposition in mahal function? I knew it works, but using my data set, mahal function did not solve with mahal function and gave an error as "the matrix is singular" since there is multicollinearity (since correlation matrix includes 1s) thanks, dilber ayhan Peter Perkins <Peteal.PerkinsRemoveThis(a)mathworks.com> wrote in message <g9jubp$pkv$1(a)fred.mathworks.com>... > Baris Yenidunya wrote: > > Hi, > > > > I'm trying to understand how mahal function in MATLAB works. > > I see that the method used is different than the MD > > calculations in the literature. How is QR decomposition used > > here? Any help (maybe references, links etc.) will be > > appreciated. > > Baris, presumably by "in the literature", you mean formulas like the one that appears in the help for MAHAL. That's fine for understanding what the Mahalanobis distance is, but not so good for computational purposes. MAHAL rewrites that explicit inversion of the cov matrix as a solution of a linear system, by noticing that the (squared) Mahalanobis distance can be expressed as > > D = Y0*S^(-1)*Y0' > = Y0*(X0'*X0)^(-1)*Y0' > = Y0*((Q*R)'*(Q*R))^(-1)*Y0' > = Y0*(R'*R)^(-1)*Y0' > = Y0*R^(-1) * (Y0*R^(-1))' > > and then noticing that you can do that using MATLAB's backslash operator. > > Hope this helps.
|
Next
|
Last
Pages: 1 2 Prev: colfilt associated function return Next: Multidimensional Sparse Matrices |