예제 #1
0
def etd_solution(P, G, L, X, ivec, r):
    # compute intermediate quantities (could be more efficient)
    di = mdputils.stationary(P) * ivec
    m = mult(resolvent(L, G, P.T), potential(G, P.T), di)
    M = np.diag(m)

    # solve the equation
    A = mult(X.T, M, potential(P, G, L), resolvent(P, G), X)
    A_inv = np.linalg.pinv(A)
    b = mult(X.T, M, potential(P, G, L), r)
    return np.array(np.dot(A_inv, b))
예제 #2
0
def etd_solution(P, G, L, X, ivec, r):
    # compute intermediate quantities (could be more efficient)
    di = mdputils.stationary(P) * ivec
    m = mult(resolvent(L, G, P.T), potential(G, P.T), di)
    M = np.diag(m)
    
    # solve the equation
    A = mult(X.T, M, potential(P, G, L), resolvent(P, G), X)
    A_inv = np.linalg.pinv(A)
    b = mult(X.T, M, potential(P, G, L), r)
    return np.array(np.dot(A_inv, b))
예제 #3
0
def td_solution(P, G, L, X, r):
    D = mdputils.distribution_matrix(P)
    A = mult(X.T, D, resolvent(P, G), X)
    A_inv = np.linalg.pinv(A)
    b = mult(X.T, D, r)
    return np.array(np.dot(A_inv, b))
예제 #4
0
def least_squares(P, G, X, r):
    """Compute the optimal weights via least squares."""
    v = bellman(P, G, r)
    D = mdputils.distribution_matrix(P)
    return np.array(mult(np.linalg.pinv(mult(X.T, D, X)), X.T, D, v))
예제 #5
0
def td_solution(P, G, L, X, r):
    D = mdputils.distribution_matrix(P)
    A = mult(X.T, D, resolvent(P, G), X)
    A_inv = np.linalg.pinv(A)
    b = mult(X.T, D, r)
    return np.array(np.dot(A_inv, b))
예제 #6
0
def least_squares(P, G, X, r):
    """Compute the optimal weights via least squares.""" 
    v = bellman(P, G, r)
    D = mdputils.distribution_matrix(P)
    return np.array(mult(np.linalg.pinv(mult(X.T, D, X)), X.T, D, v))