dora/regressors/gp/linalg.py
def choleskyjitter(A, overwrite_a = False, check_finite = True):

    """Add jitter stochastically until a positive definite matrix occurs"""
    # Avoid preparing for jittering if we can already find the cholesky 
    # with no problem
    try:
        return la.cholesky(A, lower = True, overwrite_a = overwrite_a, 
                check_finite = check_finite)
    except Exception:
        pass

    # Prepare for jittering (all the magic numbers here are arbitary...)
    n = A.shape[0]
    maxscale = 1e10
    minscale = 1e-4
    scale = minscale

    # Keep jittering stochastically, increasing the jitter magnitude along 
    # the way, until it's all good
    while scale < maxscale:

        try:
            jitA = scale * np.diag(np.random.rand(n))
            L = la.cholesky(A + jitA, lower = True, overwrite_a = overwrite_a, 
                check_finite = check_finite)
            return L
        except la.LinAlgError:
            scale *= 1.01
            log.warning('Jitter added stochastically. Scale: %f!' % scale)

    raise la.LinAlgError("Max value of jitter reached")
Add jitter stochastically until a positive definite matrix occurs
Add jitter stochastically until a positive definite matrix occurs
Add jitter stochastically until a positive definite matrix occurs
def choleskyjitter(A, overwrite_a = False, check_finite = True):
    try:
        return la.cholesky(A, lower = True, overwrite_a = overwrite_a, 
                check_finite = check_finite)
    except Exception:
        pass
    n = A.shape[0]
    maxscale = 1e10
    minscale = 1e-4
    scale = minscale
    while scale < maxscale:
        try:
            jitA = scale * np.diag(np.random.rand(n))
            L = la.cholesky(A + jitA, lower = True, overwrite_a = overwrite_a, 
                check_finite = check_finite)
            return L
        except la.LinAlgError:
            scale *= 1.01
            log.warning('Jitter added stochastically. Scale: %f!' % scale)
    raise la.LinAlgError("Max value of jitter reached")
def choleskyjitter ( A , overwrite_a = False , check_finite = True ) : try : return la . cholesky ( A , lower = True , overwrite_a = overwrite_a , check_finite = check_finite ) except Exception : pass n = A . shape [ 0 ] maxscale = 1e10 minscale = 1e-4 scale = minscale while scale < maxscale : try : jitA = scale * np . diag ( np . random . rand ( n ) ) L = la . cholesky ( A + jitA , lower = True , overwrite_a = overwrite_a , check_finite = check_finite ) return L except la . LinAlgError : scale *= 1.01 log . warning ( 'Jitter added stochastically. Scale: %f!' % scale ) raise la . LinAlgError ( "Max value of jitter reached" )
Add jitter stochastically until a positive definite matrix occurs
Add jitter stochastically until a positive definite matrix occurs
"""Add jitter stochastically until a positive definite matrix occurs""" # Avoid preparing for jittering if we can already find the cholesky  # with no problem # Prepare for jittering (all the magic numbers here are arbitary...) # Keep jittering stochastically, increasing the jitter magnitude along  # the way, until it's all good
A
overwrite_a
check_finite