Esempio n. 1
0
def test_can_calculate_transition_matrix_n_steps(
        initial_information: MarkovComponents, n: int,
        expectation: TransitionMatrix) -> None:
    ini, trans_matrix = initial_information
    mc = MarkovChain(ini, trans_matrix)

    p_matrix = mc.get_n_steps_probability_matrix(n)
    assert p_matrix == expectation, "The expected result was not found."
Esempio n. 2
0
def test_p0_matrix_is_identity(initial_information: MarkovComponents) -> None:
    ini, trans_matrix = initial_information
    mc = MarkovChain(ini, trans_matrix)

    p0_matrix = mc.get_n_steps_probability_matrix(n=0)
    expected_result = [
        [1.0, 0.0, 0.0],
        [0.0, 1.0, 0.0],
        [0.0, 0.0, 1.0],
    ]
    assert (p0_matrix == expected_result
            ), "non-identity matrix was returned for p^0 operation"