distribution
¶
Functions for manipulating probability distributions.
- pyphi.distribution.normalize(a)¶
Normalize a distribution.
- Parameters:
a (np.ndarray) – The array to normalize.
- Returns:
a
normalized so that the sum of its entries is 1.- Return type:
np.ndarray
- pyphi.distribution.uniform_distribution(number_of_nodes)¶
Return the uniform distribution for a set of binary nodes, indexed by state (so there is one dimension per node, the size of which is the number of possible states for that node).
- Parameters:
nodes (np.ndarray) – A set of indices of binary nodes.
- Returns:
The uniform distribution over the set of nodes.
- Return type:
np.ndarray
- pyphi.distribution.marginal_zero(repertoire, node_index)¶
Return the marginal probability that the node is OFF.
- pyphi.distribution.marginal(repertoire, node_index)¶
Get the marginal distribution for a node.
- pyphi.distribution.independent(repertoire)¶
Check whether the repertoire is independent.
- pyphi.distribution.purview(repertoire)¶
The purview of the repertoire.
- Parameters:
repertoire (np.ndarray) – A repertoire
- Returns:
The purview that the repertoire was computed over.
- Return type:
tuple[int]
- pyphi.distribution.purview_size(repertoire)¶
Return the size of the purview of the repertoire.
- Parameters:
repertoire (np.ndarray) – A repertoire
- Returns:
The size of purview that the repertoire was computed over.
- Return type:
int
- pyphi.distribution.repertoire_shape(all_node_indices, purview)¶
Return the shape a repertoire.
- Parameters:
all_node_indices (tuple[int]) – The node indices of the network.
purview (tuple[int]) – The indices of nodes in the repertoire.
- Returns:
The shape of the repertoire. Purview nodes have two dimensions and non-purview nodes are collapsed to a unitary dimension.
- Return type:
list[int]
Example
>>> purview = (0, 2) >>> repertoire_shape(range(3), purview) [2, 1, 2]
- pyphi.distribution.flatten(repertoire, big_endian=False)¶
Flatten a repertoire, removing empty dimensions.
By default, the flattened repertoire is returned in little-endian order.
- Parameters:
repertoire (np.ndarray or None) – A repertoire.
- Keyword Arguments:
big_endian (boolean) – If
True
, flatten the repertoire in big-endian order.- Returns:
The flattened repertoire.
- Return type:
np.ndarray
- pyphi.distribution.max_entropy_distribution(all_node_indices, purview)¶
Return the maximum entropy distribution over a set of nodes.
This is different from the network’s uniform distribution because nodes outside
node_indices
are fixed and treated as if they have only 1 state.- Parameters:
all_node_indices (tuple[int]) – The node indices of the network.
purview (tuple[int]) – The indices of nodes in the distribution.
- Returns:
The maximum entropy distribution over the set of nodes.
- Return type:
np.ndarray