def test_f_graphlasso(): # whether or not eigendecomposition is used, result should be the same assert_almost_equal(fista_gl.f_graphlasso(Theta, S), fista_gl.f_graphlasso(Theta_, S)) # minimum at max likelihood solution inv(S) assert_array_less(fista_gl.f_graphlasso(scipy.linalg.inv(S), S), fista_gl.f_graphlasso(Theta, S))
def test_Q_graphlasso(): grad = fista_gl.grad_f_graphlasso(Theta, S) Z = np.random.normal(size=(p, 2 * p)) Z = Z.dot(Z.T) / p f_Theta = fista_gl.f_graphlasso(Theta_, S) f_Z = fista_gl.f_graphlasso(Z, S) g_Z = fista_gl.g_graphlasso(Z, .5) L = np.sqrt(np.sum(1. / scipy.linalg.eigvalsh(Z) ** 2)) L *= np.sqrt(np.sum(1. / Theta_[0] ** 2)) assert_array_less(f_Z + g_Z, fista_gl.Q_graphlasso(Z, Theta, grad, L, .5, f_Theta)) # Does this hold for the Hessian update ? gradH = fista_gl.grad_f_graphlasso(Theta, S, Hessian=True) assert_array_less(f_Z + g_Z, fista_gl.Q_graphlasso(Z, Theta, gradH, L, .5, f_Theta))