Inversion of a singular matrix
조회 수: 3 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Matt J
2021년 11월 8일
편집: Matt J
2021년 11월 8일
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.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Discriminant Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!