Esempio n. 1
0
def get_whitener( A, k ):
    """Return the matrix W that whitens A, i.e. W^T A W = I. Assumes A
    is k-rank"""

    U, D, V = svdk(A, k)
    Ds = sqrt(D)
    Di = 1./Ds
    return U.dot(diag(Di)), U.dot(diag(Ds))
Esempio n. 2
0
def get_whitener( A, k ):
    """Return the matrix W that whitens A, i.e. W^T A W = I. Assumes A
    is k-rank"""

    #assert( mrank( A ) == k )
    # Verify PSD
    e = eigvals( A )[:k].real
    if not (e >= 0).all():
      print "Warning: Not PSD"
      print e

    # If A is PSD
    U, _, _ = svdk( A, k )
    A2 = cholesky( U.T.dot( A ).dot( U ) )
    W, Wt = U.dot( pinv( A2 ) ), U.dot( A2 )
    
    return W, Wt
Esempio n. 3
0
def get_whitener(A, k):
    """Return the matrix W that whitens A, i.e. W^T A W = I. Assumes A
    is k-rank"""

    #assert( mrank( A ) == k )
    # Verify PSD
    e = eigvals(A)[:k].real
    if not (e >= 0).all():
        print "Warning: Not PSD"
        print e

    # If A is PSD
    U, _, _ = svdk(A, k)
    A2 = cholesky(U.T.dot(A).dot(U))
    W, Wt = U.dot(pinv(A2)), U.dot(A2)

    return W, Wt