I try to implement Unscented Kalman Filter. Everything seems to be done correctly but I do receive an error about Cholesky decomposition

raise LinAlgError('Matrix is not positive definite - '
numpy.linalg.linalg.LinAlgError: Matrix is not positive definite - Cholesky decomposition     cannot be computed

The problem is that the fail occurs always after some runs of the algorithm. I keep checking determinant and it's not zero. I tried to remove dependencies from the model.

I don't have any idea how to proceed from now.

I don't know it it will be any help, but this is my python's implementation of Sigma point:

def SigmaPoints(xm, P, kappa):
    ''' SigmaPoints calculation'''
    n = len(xm)   
    xm = np.asmatrix(xm)         # checks how big is state vector
    Xi = np.asmatrix(np.zeros((n,n*2+1)))# creates zero matrix sigmaPoints n-rows, 2n+1 col  
    W = np.zeros((n*2+1,1)) # weights for each sigmaPoint as a vector
    Xi[:,0] = xm            # 1st column init to input xm          
    W[0] = kappa*1.0/(n+kappa) # update first weight
    U = np.linalg.cholesky(P*(n+kappa)) #  returns identityMat * value
    for k in range(n):      
        Xi[:,k] = xm + U[k-1, :].T
        W[k] = 1.0/(2.0*(n+kappa))
    for k in range(n):        
        Xi[:, n+k] = xm - U[k-1,:].T
    return (Xi, W)
  • $\begingroup$ There's nothing in your code that can help us say any more than the error message does (your matrix is not positive definite), because it reveals nothing at all about the values of P, n, or kappa which form the argument to the Cholesky decomposition. As Mike Nute points out, checking the determinant does you no good. Even two by two matrices with positive determinant can be non-positive definite (such as any diagonal matrix with two negative values). $\endgroup$
    – whuber
    Commented Aug 14, 2013 at 19:08
  • $\begingroup$ I have voted to close this question because you haven't responded to the request for information needed to answer it. $\endgroup$
    – whuber
    Commented Sep 13, 2013 at 19:22
  • 1
    $\begingroup$ @whuber thank you for the input. The problem was in the model, not the Cholesky procedure. in the model I had some dependency, which turned up to crop up in some situations. Probably I should really need to completely re-write the question, but it would be different story. If anyone provide the answer such "start with analysing dependences in the model ..." I would be very happy to accept the answer, although thank you very much for what was already written. $\endgroup$
    – tomasz74
    Commented Sep 14, 2013 at 20:59

2 Answers 2


Having positive determinant does not necessarily imply positive definite for a matrix. All of the individual eigenvalues must be positive.


The covariance matrix is not positive definite that is why you receive this message.

This is mainly because the weight w^(0) is negative and causes the estimated covariance matrix through weighted averaging to be negative definite.

  • $\begingroup$ What does your notation "w^(0)" refer to and what does it have to do with the Cholesky decomposition shown in the code snippet? $\endgroup$
    – whuber
    Commented Aug 14, 2013 at 19:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.