Example #1
0
File: train.py Project: NICTA/dora
def chol_up_insert(L, V12, V23, V22, Snn_noise_std_vec, insertionID):

    R = L.T
    N = R.shape[0]
    n = V22.shape[0]
    noise = np.diag(Snn_noise_std_vec ** 2)
    R11 = R[:insertionID, :insertionID]
    R33 = R[insertionID:, insertionID:]
    S11 = R11
    S12 = la.solve_triangular(R11.T, V12, lower=True)
    S13 = R[:insertionID, insertionID:]
    S22 = linalg.jitchol(V22 + noise - S12.T.dot(S12)).T
    if V23.shape[1] != 0:  # The data is being inserted between columns
        S23 = la.solve_triangular(S22.T, (V23 - S12.T.dot(S13)), lower=True)
        S33 = linalg.jitchol(R33.T.dot(R33) - S23.T.dot(S23)).T
    else:  # the data is being appended at the end of the matrix
        S23 = np.zeros((n, 0))
        S33 = np.zeros((0, 0))
    On1 = np.zeros((n, insertionID))
    On2 = np.zeros((N - insertionID, insertionID))
    On3 = np.zeros((N - insertionID, n))

    top = np.concatenate((S11, S12, S13), axis=1)
    middle = np.concatenate((On1, S22, S23), axis=1)
    bottom = np.concatenate((On2, On3, S33), axis=1)
    return np.concatenate((top, middle, bottom), axis=0).T
Example #2
0
def chol_up_insert(L, V12, V23, V22, Snn_noise_std_vec, insertionID):

    R = L.T
    N = R.shape[0]
    n = V22.shape[0]
    noise = np.diag(Snn_noise_std_vec**2)
    R11 = R[:insertionID, :insertionID]
    R33 = R[insertionID:, insertionID:]
    S11 = R11
    S12 = la.solve_triangular(R11.T, V12, lower=True)
    S13 = R[:insertionID, insertionID:]
    S22 = linalg.jitchol(V22 + noise - S12.T.dot(S12)).T
    if V23.shape[1] != 0:  # The data is being inserted between columns
        S23 = la.solve_triangular(S22.T, (V23 - S12.T.dot(S13)), lower=True)
        S33 = linalg.jitchol(R33.T.dot(R33) - S23.T.dot(S23)).T
    else:  #the data is being appended at the end of the matrix
        S23 = np.zeros((n, 0))
        S33 = np.zeros((0, 0))
    On1 = np.zeros((n, insertionID))
    On2 = np.zeros((N - insertionID, insertionID))
    On3 = np.zeros((N - insertionID, n))

    top = np.concatenate((S11, S12, S13), axis=1)
    middle = np.concatenate((On1, S22, S23), axis=1)
    bottom = np.concatenate((On2, On3, S33), axis=1)
    return np.concatenate((top, middle, bottom), axis=0).T
Example #3
0
File: train.py Project: NICTA/dora
def chol_up(L, Sn, Snn, Snn_noise_std_vec):
    # Incremental cholesky update
    Ln = la.solve_triangular(L, Sn, lower=True).T
    On = np.zeros(Ln.shape).T
    noise = np.diag(Snn_noise_std_vec ** 2)
    Lnn = linalg.jitchol(Snn + noise - Ln.dot(Ln.T))
    top = np.concatenate((L, On), axis=1)
    bottom = np.concatenate((Ln, Lnn), axis=1)
    return np.concatenate((top, bottom), axis=0)
Example #4
0
def chol_up(L, Sn, Snn, Snn_noise_std_vec):
    # Incremental cholesky update
    Ln = la.solve_triangular(L, Sn, lower=True).T
    On = np.zeros(Ln.shape).T
    noise = np.diag(Snn_noise_std_vec**2)
    Lnn = linalg.jitchol(Snn + noise - Ln.dot(Ln.T))
    top = np.concatenate((L, On), axis=1)
    bottom = np.concatenate((Ln, Lnn), axis=1)
    return np.concatenate((top, bottom), axis=0)
Example #5
0
def draws(ndraws, exp, cov):

    # S: Standard Draw
    # C: Transform to include covariance
    # D: Transform to include expectance
    L = linalg.jitchol(cov)
    S = np.random.normal(loc=0.0, scale=1.0, size=(exp.shape[0], ndraws))
    C = np.dot(L, S)
    D = (C.T + exp)
    return D
Example #6
0
File: train.py Project: NICTA/dora
def chol_down(L, remIDList):
    # This works but it might potentially be slower than the naive approach of
    # recomputing the cholesky decomposition from scratch.
    # The jitchol line can apparently be replaces with a chol that exploits the
    # structure of the problem according to Osbourne's Thesis (as
    # cholupdate does).
    remIDList = np.sort(remIDList)
    for i in range(len(remIDList)):
        remID = remIDList[i]
        S = L.T
        n = S.shape[0]
        On = np.zeros((n - (remID + 1), remID))
        # Incremental cholesky downdate
        top = np.concatenate((S[:remID, :remID], S[:(remID), (remID + 1) :]), axis=1)
        S23 = S[remID, (remID + 1) :][np.newaxis, :]
        S23TS23 = S23.T.dot(S23)
        S33TS33 = S[(remID + 1) :, (remID + 1) :].T.dot(S[(remID + 1) :, (remID + 1) :])
        R33 = linalg.jitchol(S23TS23 + S33TS33).T
        bottom = np.concatenate((On, R33), axis=1)
        L = np.concatenate((top, bottom), axis=0).T
        remIDList -= 1
    return L
Example #7
0
def chol_down(L, remIDList):
    # This works but it might potentially be slower than the naive approach of
    # recomputing the cholesky decomposition from scratch.
    # The jitchol line can apparently be replaces with a chol that exploits the
    # structure of the problem according to Osbourne's Thesis (as
    # cholupdate does).
    remIDList = np.sort(remIDList)
    for i in range(len(remIDList)):
        remID = remIDList[i]
        S = L.T
        n = S.shape[0]
        On = np.zeros((n - (remID + 1), remID))
        # Incremental cholesky downdate
        top = np.concatenate((S[:remID, :remID], S[:(remID), (remID + 1):]),
                             axis=1)
        S23 = S[remID, (remID + 1):][np.newaxis, :]
        S23TS23 = S23.T.dot(S23)
        S33TS33 = S[(remID + 1):, (remID + 1):].T.dot(S[(remID + 1):,
                                                        (remID + 1):])
        R33 = linalg.jitchol(S23TS23 + S33TS33).T
        bottom = np.concatenate((On, R33), axis=1)
        L = np.concatenate((top, bottom), axis=0).T
        remIDList -= 1
    return L