# Computing the Inverse of Co-variance Matrix results in "Inf". What could be the problem?

13 views (last 30 days)

Show older comments

prashanth A
on 22 Jul 2014

Commented: Bruno Luong
on 29 Oct 2018

I have Computed the Covariance Matrix in Matlab for one of my program. Then eventually i want to calculate the Mahalanobis Distance, which will need the Inverse of the same.

But the entries in my Covariance matrix are very small and many are zeros.

The message that i get when inverse is tried to be found is :

- Warning: Matrix is singular to working precision. *

what is the meaning of all this? how can i proceed further? Please suggest me.

regards

Prashanth

##### 0 Comments

### Accepted Answer

Roger Stafford
on 22 Jul 2014

##### 2 Comments

Nadir Nibras
on 29 Oct 2018

Bruno Luong
on 29 Oct 2018

### More Answers (1)

Shyam Sangaraju
on 22 Jul 2014

“Warning: Matrix is singular to working precision” indicates that you have encountered a round off error that demonstrates a fundamental problem with the way computers deal with numbers. Machines use a finite number of bits to represent any number (in MATLAB's case, 64 bits are used), if a matrix has very small numbers then some precision is lost because the computer has difficulty representing the numbers accurately. When you try to find the inverse of a near singular matrix, you may receive this warning.

Please use the MATLAB function “rcond” to find whether the matrix is near to singular or not. Following sample code demonstrates how to use “rcond” function:

if( rcond(A) < 1e-12 )

% This matrix doesn't look good.

end

‘A’ is the matrix for which we are trying to find inverse.

In this example “1e-12” is used as cut off between singular and non-singular matrix, you can use a value that suits your need.

##### 0 Comments

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!