Exemplo n.º 1
0
def test_calc_Lambda_b(expected_scatter_matrices, expected_W,
                       expected_Lambda_b):
    S_b = expected_scatter_matrices['S_b']
    W = expected_W

    actual_Lambda_b = calc_Lambda_b(S_b, W)

    assert_allclose(actual_Lambda_b, expected_Lambda_b, rtol=1e-8)
    assert_diagonal(actual_Lambda_b, atol=1e-6)
Exemplo n.º 2
0
def test_calc_Lambda_w(expected_scatter_matrices, expected_W,
                       expected_Lambda_w):
    S_w = expected_scatter_matrices['S_w']
    W = expected_W
    dim = W.shape[0]

    actual_Lambda_w = calc_Lambda_b(S_w, W)

    assert_allclose(actual_Lambda_w, expected_Lambda_w, rtol=1e-8)
    assert_diagonal(actual_Lambda_w, atol=1e-6)
    assert_allclose(np.eye(dim), actual_Lambda_w, atol=1e-6)
Exemplo n.º 3
0
def test_calc_Psi():
    np.random.seed(1234)

    N = 1234
    K = 34
    n_avg = N / K

    dim = 5
    Lambda_b = np.diag(np.random.randint(1, 100, dim))
    Lambda_w = np.eye(dim)

    expected_Psi = (n_avg - 1) / n_avg * Lambda_b.diagonal() - (1 / n_avg)
    expected_Psi[expected_Psi < 0] = 0
    expected_Psi = np.diag(expected_Psi)

    actual_Psi = calc_Psi(Lambda_w, Lambda_b, n_avg)

    assert_diagonal(actual_Psi)
    assert_allclose(actual_Psi, expected_Psi)
    assert_allclose(actual_Psi.diagonal(), expected_Psi.diagonal())