pyphi.convert.state_by_state2state_by_node#

pyphi.convert.state_by_state2state_by_node(tpm)[source]#

Convert a state-by-state TPM to a state-by-node TPM.

Danger

A single state-by-node TPM can represent many distinct nondeterministic state-by-state TPMs. The mapping is made one-to-one by assuming that the state-by-state TPM is conditionally independent, as this function does. If the given TPM is not conditionally independent, the conditional dependencies are silently lost.

Note

The rows and columns of the state-by-state TPM are assumed to follow the little-endian convention, and the rows of the resulting state-by-node TPM also follow the little-endian convention. See the PyPhi documentation on Transition probability matrix conventions for more information.

Parameters:

tpm (list[list] or np.ndarray) – A square state-by-state TPM with row and column indices following the little-endian convention.

Returns:

np.ndarray – A state-by-node TPM, with row indices following the little-endian convention.

Examples

>>> tpm = np.array([[0.5, 0.5, 0.0, 0.0],
...                 [0.0, 1.0, 0.0, 0.0],
...                 [0.0, 0.2, 0.0, 0.8],
...                 [0.0, 0.3, 0.7, 0.0]])
>>> state_by_state2state_by_node(tpm)
array([[[0.5, 0. ],
        [1. , 0.8]],

       [[1. , 0. ],
        [0.3, 0.7]]])