Esempio n. 1
0
def test_amari_distance(n=16, tol=1e-6):
    """Amari distance between matrix and its inverse should be 0."""
    rng = np.random.RandomState(123)

    A = rng.randn(n, n)
    W = np.linalg.inv(A)
    X = np.linalg.pinv(A)

    np.testing.assert_allclose(amari(W, A), 0.0, rtol=tol)
    np.testing.assert_allclose(amari(A, A), 2.912362, rtol=tol)
    np.testing.assert_allclose(amari(X, A), 0.0, rtol=tol)
Esempio n. 2
0
def test_orthomax(whiten_method):
    rng = np.random.RandomState(123)
    S = rng.laplace(size=(3, 500))
    A = rng.random((3, 3))
    s = Signal1D(A @ S)
    s.decomposition()
    s.blind_source_separation(3, algorithm="orthomax", whiten_method=whiten_method)

    W = s.learning_results.unmixing_matrix
    assert amari(W, A) < 0.5

    # Verify that we can change gamma for orthomax method
    s = artificial_data.get_core_loss_eels_line_scan_signal()
    s.decomposition()
    s.blind_source_separation(2, algorithm="orthomax", gamma=2)