Date: May. 11th
Author: take.sei
c.f. http://pyphi.readthedocs.io/en/stable/index.html
import numpy as np
import pyphi
# 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.
# 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"))
# compute the phi of subsystem.
pyphi.compute.phi(subsystem)
2.3125
# when you want to take deeper info, use sia()
sia = pyphi.compute.sia(subsystem)
sia
┌──────────────────────────────────────────────────────────────┐ │ System irreducibility analysis: Φ = 37/16 │ │ Cut [B, C] ━━/ /━━➤ [A] │ │ Subsystem(A, B, C) │ │ ════════════════════════════════════════════════════════════ │ │ Cause-effect structure (4 concepts) │ │ ════════════════════════════════════════════════════════════ │ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │ Concept: Mechanism = [B], φ = 1/4 │ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │ MIC MIE │ │ ┌──────────────────────────┐┌──────────────────────────┐ │ │ │ φ = 1/2 ││ φ = 1/4 │ │ │ │ Purview = [C] ││ Purview = [A] │ │ │ │ MIP: ││ MIP: │ │ │ │ ∅ B ││ ∅ B │ │ │ │ ─── ✕ ─── ││ ─── ✕ ─── │ │ │ │ C ∅ ││ A ∅ │ │ │ │ Repertoire: ││ Repertoire: │ │ │ │ ┌────────────┐ ││ ┌────────────┐ │ │ │ │ │ S P(S) │ ││ │ S P(S) │ │ │ │ │ │ ╴╴╴╴╴╴╴╴╴╴ │ ││ │ ╴╴╴╴╴╴╴╴╴╴ │ │ │ │ │ │ 0 1 │ ││ │ 0 1/2 │ │ │ │ │ │ 1 0 │ ││ │ 1 1/2 │ │ │ │ │ └────────────┘ ││ └────────────┘ │ │ │ │ Partitioned repertoire: ││ Partitioned repertoire: │ │ │ │ ┌────────────┐ ││ ┌────────────┐ │ │ │ │ │ S P(S) │ ││ │ S P(S) │ │ │ │ │ │ ╴╴╴╴╴╴╴╴╴╴ │ ││ │ ╴╴╴╴╴╴╴╴╴╴ │ │ │ │ │ │ 0 1/2 │ ││ │ 0 1/4 │ │ │ │ │ │ 1 1/2 │ ││ │ 1 3/4 │ │ │ │ │ └────────────┘ ││ └────────────┘ │ │ │ └──────────────────────────┘└──────────────────────────┘ │ │ │ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │ Concept: Mechanism = [C], φ = 1/2 │ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │ MIC MIE │ │ ┌──────────────────────────┐┌──────────────────────────┐ │ │ │ φ = 1/2 ││ φ = 1/2 │ │ │ │ Purview = [A, B] ││ Purview = [B] │ │ │ │ MIP: ││ MIP: │ │ │ │ ∅ C ││ ∅ C │ │ │ │ ─── ✕ ─── ││ ─── ✕ ─── │ │ │ │ A B ││ B ∅ │ │ │ │ Repertoire: ││ Repertoire: │ │ │ │ ┌─────────────┐ ││ ┌────────────┐ │ │ │ │ │ S P(S) │ ││ │ S P(S) │ │ │ │ │ │ ╴╴╴╴╴╴╴╴╴╴╴ │ ││ │ ╴╴╴╴╴╴╴╴╴╴ │ │ │ │ │ │ 00 1/2 │ ││ │ 0 1 │ │ │ │ │ │ 10 0 │ ││ │ 1 0 │ │ │ │ │ │ 01 0 │ ││ └────────────┘ │ │ │ │ │ 11 1/2 │ ││ Partitioned repertoire: │ │ │ │ └─────────────┘ ││ ┌────────────┐ │ │ │ │ Partitioned repertoire: ││ │ S P(S) │ │ │ │ │ ┌─────────────┐ ││ │ ╴╴╴╴╴╴╴╴╴╴ │ │ │ │ │ │ S P(S) │ ││ │ 0 1/2 │ │ │ │ │ │ ╴╴╴╴╴╴╴╴╴╴╴ │ ││ │ 1 1/2 │ │ │ │ │ │ 00 1/4 │ ││ └────────────┘ │ │ │ │ │ 10 1/4 │ │└──────────────────────────┘ │ │ │ │ 01 1/4 │ │ │ │ │ │ 11 1/4 │ │ │ │ │ └─────────────┘ │ │ │ └──────────────────────────┘ │ │ │ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │ Concept: Mechanism = [A, B], φ = 1/3 │ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │ MIC MIE │ │ ┌──────────────────────────┐┌──────────────────────────┐ │ │ │ φ = 1/3 ││ φ = 1/2 │ │ │ │ Purview = [B, C] ││ Purview = [C] │ │ │ │ MIP: ││ MIP: │ │ │ │ A B ││ ∅ A,B │ │ │ │ ─── ✕ ─── ││ ─── ✕ ─── │ │ │ │ B C ││ C ∅ │ │ │ │ Repertoire: ││ Repertoire: │ │ │ │ ┌─────────────┐ ││ ┌────────────┐ │ │ │ │ │ S P(S) │ ││ │ S P(S) │ │ │ │ │ │ ╴╴╴╴╴╴╴╴╴╴╴ │ ││ │ ╴╴╴╴╴╴╴╴╴╴ │ │ │ │ │ │ 00 0 │ ││ │ 0 0 │ │ │ │ │ │ 10 1 │ ││ │ 1 1 │ │ │ │ │ │ 01 0 │ ││ └────────────┘ │ │ │ │ │ 11 0 │ ││ Partitioned repertoire: │ │ │ │ └─────────────┘ ││ ┌────────────┐ │ │ │ │ Partitioned repertoire: ││ │ S P(S) │ │ │ │ │ ┌─────────────┐ ││ │ ╴╴╴╴╴╴╴╴╴╴ │ │ │ │ │ │ S P(S) │ ││ │ 0 1/2 │ │ │ │ │ │ ╴╴╴╴╴╴╴╴╴╴╴ │ ││ │ 1 1/2 │ │ │ │ │ │ 00 1/3 │ ││ └────────────┘ │ │ │ │ │ 10 2/3 │ │└──────────────────────────┘ │ │ │ │ 01 0 │ │ │ │ │ │ 11 0 │ │ │ │ │ └─────────────┘ │ │ │ └──────────────────────────┘ │ │ │ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │ Concept: Mechanism = [A, B, C], φ = 1/2 │ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │ MIC MIE │ │ ┌──────────────────────────┐┌──────────────────────────┐ │ │ │ φ = 1/2 ││ φ = 1/2 │ │ │ │ Purview = [A, B, C] ││ Purview = [A, B, C] │ │ │ │ MIP: ││ MIP: │ │ │ │ ∅ A,B,C ││ ∅ A,B,C │ │ │ │ ─── ✕ ───── ││ ─── ✕ ───── │ │ │ │ A B,C ││ B A,C │ │ │ │ Repertoire: ││ Repertoire: │ │ │ │ ┌──────────────┐ ││ ┌──────────────┐ │ │ │ │ │ S P(S) │ ││ │ S P(S) │ │ │ │ │ │ ╴╴╴╴╴╴╴╴╴╴╴╴ │ ││ │ ╴╴╴╴╴╴╴╴╴╴╴╴ │ │ │ │ │ │ 000 0 │ ││ │ 000 0 │ │ │ │ │ │ 100 0 │ ││ │ 100 0 │ │ │ │ │ │ 010 0 │ ││ │ 010 0 │ │ │ │ │ │ 110 1 │ ││ │ 110 0 │ │ │ │ │ │ 001 0 │ ││ │ 001 1 │ │ │ │ │ │ 101 0 │ ││ │ 101 0 │ │ │ │ │ │ 011 0 │ ││ │ 011 0 │ │ │ │ │ │ 111 0 │ ││ │ 111 0 │ │ │ │ │ └──────────────┘ ││ └──────────────┘ │ │ │ │ Partitioned repertoire: ││ Partitioned repertoire: │ │ │ │ ┌──────────────┐ ││ ┌──────────────┐ │ │ │ │ │ S P(S) │ ││ │ S P(S) │ │ │ │ │ │ ╴╴╴╴╴╴╴╴╴╴╴╴ │ ││ │ ╴╴╴╴╴╴╴╴╴╴╴╴ │ │ │ │ │ │ 000 0 │ ││ │ 000 0 │ │ │ │ │ │ 100 0 │ ││ │ 100 0 │ │ │ │ │ │ 010 1/2 │ ││ │ 010 0 │ │ │ │ │ │ 110 1/2 │ ││ │ 110 0 │ │ │ │ │ │ 001 0 │ ││ │ 001 1/2 │ │ │ │ │ │ 101 0 │ ││ │ 101 0 │ │ │ │ │ │ 011 0 │ ││ │ 011 1/2 │ │ │ │ │ │ 111 0 │ ││ │ 111 0 │ │ │ │ │ └──────────────┘ ││ └──────────────┘ │ │ │ └──────────────────────────┘└──────────────────────────┘ │ │ │ │ ════════════════════════════════════════════════════════════ │ │ Partitioned cause-effect structure (1 concept) │ │ ════════════════════════════════════════════════════════════ │ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │ Concept: Mechanism = [C], φ = 1/2 │ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │ MIC MIE │ │ ┌──────────────────────────┐┌──────────────────────────┐ │ │ │ φ = 1/2 ││ φ = 1/2 │ │ │ │ Purview = [A, B] ││ Purview = [B] │ │ │ │ MIP: ││ MIP: │ │ │ │ ∅ C ││ ∅ C │ │ │ │ ─── ✕ ─── ││ ─── ✕ ─── │ │ │ │ A B ││ B ∅ │ │ │ │ Repertoire: ││ Repertoire: │ │ │ │ ┌─────────────┐ ││ ┌────────────┐ │ │ │ │ │ S P(S) │ ││ │ S P(S) │ │ │ │ │ │ ╴╴╴╴╴╴╴╴╴╴╴ │ ││ │ ╴╴╴╴╴╴╴╴╴╴ │ │ │ │ │ │ 00 1/2 │ ││ │ 0 1 │ │ │ │ │ │ 10 0 │ ││ │ 1 0 │ │ │ │ │ │ 01 0 │ ││ └────────────┘ │ │ │ │ │ 11 1/2 │ ││ Partitioned repertoire: │ │ │ │ └─────────────┘ ││ ┌────────────┐ │ │ │ │ Partitioned repertoire: ││ │ S P(S) │ │ │ │ │ ┌─────────────┐ ││ │ ╴╴╴╴╴╴╴╴╴╴ │ │ │ │ │ │ S P(S) │ ││ │ 0 1/2 │ │ │ │ │ │ ╴╴╴╴╴╴╴╴╴╴╴ │ ││ │ 1 1/2 │ │ │ │ │ │ 00 1/4 │ ││ └────────────┘ │ │ │ │ │ 10 1/4 │ │└──────────────────────────┘ │ │ │ │ 01 1/4 │ │ │ │ │ │ 11 1/4 │ │ │ │ │ └─────────────┘ │ │ │ └──────────────────────────┘ │ │ │ │ │ └──────────────────────────────────────────────────────────────┘