#!/usr/bin/env python # coding: utf-8 # # Computing phi w/ pyphi # Date: May. 11th # Author: take.sei # c.f. http://pyphi.readthedocs.io/en/stable/index.html # In[3]: import numpy as np import pyphi # In[6]: # define network using tpm and connectivity matrix(optional). # docs for Network: http://pyphi.readthedocs.io/en/stable/api/network.html#pyphi.network.Network tpm = np.array([ [0, 0, 0], [0, 0, 1], [1, 0, 1], [1, 0, 0], [1, 1, 0], [1, 1, 1], [1, 1, 1], [1, 1, 0] ]) cm = np.array([ [0, 0, 1], [1, 0, 1], [1, 1, 0] ]) labels = ("A", "B", "C") # labels makes outputs easier network = pyphi.Network(tpm, cm=cm, node_labels=labels) # 3-node net. # In[7]: # Define a subsystem. Use network and its state, indices of nodes subset. state = 1, 0, 0 node_indices = 0, 1, 2 subsystem = pyphi.Subsystem(network, state, node_indices) # labels can be used instead of indices. # pyphi.Subsystem(network, state, ("B", "C")) # In[9]: # compute the phi of subsystem. pyphi.compute.phi(subsystem) # In[12]: # when you want to take deeper info, use sia() sia = pyphi.compute.sia(subsystem) sia # In[ ]: