# tpm¶

Functions for manipulating transition probability matrices.

pyphi.tpm.tpm_indices(tpm)

Return the indices of nodes in the TPM.

pyphi.tpm.is_deterministic(tpm)

Return whether the TPM is deterministic.

pyphi.tpm.is_state_by_state(tpm)

Return True if tpm is in state-by-state form, otherwise False.

pyphi.tpm.tpm2df(tpm, num_states_per_node, node_labels)
pyphi.tpm.condition_tpm_nb(tpm, fixed_nodes, state, num_states_per_node=None, node_labels=None, node_indices=None)
pyphi.tpm.condition_tpm(tpm, fixed_nodes, state)

Return a TPM conditioned on the given fixed node indices, whose states are fixed according to the given state-tuple.

The dimensions of the new TPM that correspond to the fixed nodes are collapsed onto their state, making those dimensions singletons suitable for broadcasting. The number of dimensions of the conditioned TPM will be the same as the unconditioned TPM.

pyphi.tpm.expand_tpm(tpm)

Broadcast a state-by-node TPM so that singleton dimensions are expanded over the full network.

pyphi.tpm.marginalize_out(node_indices, tpm)

Marginalize out nodes from a TPM.

Parameters
• node_indices (list[int]) – The indices of nodes to be marginalized out.

• tpm (np.ndarray) – The TPM to marginalize the node out of.

Returns

A TPM with the same number of dimensions, with the nodes marginalized out.

Return type

np.ndarray

pyphi.tpm.infer_edge_nb(tpm, a, b, contexts)

Infer the presence or absence of an edge from node A to node B.

Let $$S$$ be the set of all nodes in a network. Let $$A' = S - \{A\}$$. We call the state of $$A'$$ the context $$C$$ of $$A$$. There is an edge from $$A$$ to $$B$$ if there exists any context $$C(A)$$ such that $$\Pr(B \mid C(A), A = 0) \neq \Pr(B \mid C(A), A = 1)$$.

Parameters
• tpm (np.ndarray) – The TPM in state-by-node, multidimensional form.

• a (int) – The index of the putative source node.

• b (int) – The index of the putative sink node.

Returns

True if the edge $$A \rightarrow B$$ exists, False otherwise.

Return type

bool

pyphi.tpm.infer_cm_nb(tpm)

Infer the connectivity matrix associated with a state-by-node TPM in multidimensional form.

pyphi.tpm.infer_edge(tpm, a, b, contexts)

Infer the presence or absence of an edge from node A to node B. Let $$S$$ be the set of all nodes in a network. Let $$A' = S - \{A\}$$. We call the state of $$A'$$ the context $$C$$ of $$A$$. There is an edge from $$A$$ to $$B$$ if there exists any context $$C(A)$$ such that $$\Pr(B \mid C(A), A = 0) \neq \Pr(B \mid C(A), A = 1)$$. :param tpm: The TPM in state-by-node, multidimensional form. :type tpm: np.ndarray :param a: The index of the putative source node. :type a: int :param b: The index of the putative sink node. :type b: int

Returns

True if the edge $$A \rightarrow B$$ exists, False otherwise.

Return type

bool

pyphi.tpm.infer_cm(tpm)

Infer the connectivity matrix associated with a state-by-node TPM in multidimensional form.

pyphi.tpm.reconstitute_tpm(subsystem)

Reconstitute the TPM of a subsystem using the individual node TPMs.

pyphi.tpm.tensor(a, b)
pyphi.tpm.cut_tpm(subsystem, from_nodes, to_nodes)
pyphi.tpm.cut_node_tpms(subsystem, from_nodes, to_nodes)
pyphi.tpm.expand_node_tpms(subsystem, node_tpms)