Inversion of a singular matrix

2 views (last 30 days)
Alba GC
Alba GC on 8 Nov 2021
Edited: Matt J on 8 Nov 2021
Hello everyone,
I have a question that may sound akward, but I need to know. First, let me recall the discriminant function for a k-classes classification problem with Linear Discriminant Analysis (LDA).
I have a binary classification problem with a predictor matrix (X) of sizes NxK = 29x1018. I woud not expect a solution with LDA, given that the resulting covariance matrix would not be invertible. However, when I applied the fitcdiscr.m function it returns me a solution. Nonetheless, when I check the determinant of the covariance matrix (returned as an output from the returned Classification Discriminant object), it is, indeed, null.
So, do you have any explanation for this? I guess that the function internally does some type of "trick" to get an invertible matrix, but I could not reach that level of depth even by looking inside the matlab code (or maybe I am just missing something).
Find attached an example of X and Y elements slong with the code lines used to fit the LDA model and to check the determinant of the returned covariance matrix:
MdlLinear = fitcdiscr(xtrain,ytrain);
det(MdlLinear.Sigma)
Thank you so much in advance

Accepted Answer

Matt J
Matt J on 8 Nov 2021
Edited: Matt J on 8 Nov 2021
I don't know what fitcdiscr does internally, but we can be quite certain Matlab would never invert a matrix explicitly, even if it were non-singular. To calculate , it would instead solve the system of equations . The solutions to these equations are non-unique in this case, but Matlab has many linear solvers at its disposible that will extract one of the solutions from a singular system.

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!