econml/tests/test_dml.py
def rand_sol(A, b):
    """Generate a random solution to the equation Ax=b."""
    assert np.linalg.matrix_rank(A) <= len(b)
    A_plus = np.linalg.pinv(A)
    x = A_plus @ b
    return x + (np.eye(x.shape[0]) - A_plus @ A) @ np.random.normal(size=x.shape)
Generate a random solution to the equation Ax=b.
Generate a random solution to the equation Ax=b.
Generate a random solution to the equation Ax = b .
def rand_sol(A, b):
    assert np.linalg.matrix_rank(A) <= len(b)
    A_plus = np.linalg.pinv(A)
    x = A_plus @ b
    return x + (np.eye(x.shape[0]) - A_plus @ A) @ np.random.normal(size=x.shape)
def rand_sol ( A , b ) : assert np . linalg . matrix_rank ( A ) <= len ( b ) A_plus = np . linalg . pinv ( A ) x = A_plus @ b return x + ( np . eye ( x . shape [ 0 ] ) - A_plus @ A ) @ np . random . normal ( size = x . shape )
Generate a random solution to the equation Ax=b.
Generate a random solution to the equation Ax = b .
"""Generate a random solution to the equation Ax=b."""
A
b