[SciPy-User] Cholesky for semi-definite matrices?

eat e.antero.tammi at gmail.com
Sat Jul 9 13:36:01 EDT 2011


Hi,

On Sat, Jul 9, 2011 at 6:19 PM, Nathaniel Smith <njs at pobox.com> wrote:

> Hi all,
>
> I've run into a case where it'd be convenient to be able to compute
> the Cholesky decomposition of a semi-definite matrix. (It's a
> covariance matrix computed from not-enough samples, so it's positive
> semi-definite but rank-deficient.) As any schoolchild knows, the
> Cholesky is well defined for such cases, but I guess that shows why
> you shouldn't trust schoolchildren, because I guess the standard
> implementations blow up if you try:
>
> In [155]: np.linalg.cholesky([[1, 0], [0, 0]])
> LinAlgError: Matrix is not positive definite -         Cholesky
> decomposition cannot be computed
>
> Is there an easy way to do this?
>
How bout a slight regularization, like:
In []: A
Out[]:
array([[1, 0],
       [0, 0]])
In []: A+ 1e-14* eye(2)
Out[]:
array([[  1.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   1.00000000e-14]])

In []: L= linalg.cholesky(A+ 1e-14* eye(2))
In []: dot(L, L.T)
Out[]:
array([[  1.00000000e+00,   0.00000000e+00],
       [  0.00000000e+00,   1.00000000e-14]])

My 2 cents,
- eat

>
> -- Nathaniel
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110709/61a25d89/attachment.html>


More information about the SciPy-User mailing list