Supreme court: Analysis in the best basis

[1]:
# Imports
import numpy as np
from mcmpy import Data, MCM, MCMSearch, Basis, BasisSearch

Initialization

[2]:
# Data object

n = 9   # Number of variables
q = 2   # Number of states
data = Data('../../input/US_SupremeCourt_n9_N895.dat', n, q)

print("The dataset contains %i datapoints, of which %i different ones." %(data.N, data.N_unique))
The dataset contains 895 datapoints, of which 128 different ones.
[3]:
# Search objects
basis_searcher = BasisSearch()
mcm_searcher = MCMSearch()

Search for the best basis representation

[4]:
# The system is small enough to perform an exhaustive search
opt_basis = basis_searcher.exhaustive(data)
opt_basis.print_details()
Operator 1:     000100100        Indices: 3     6
Operator 2:     000001010        Indices: 5     7
Operator 3:     000000011        Indices: 7     8
Operator 4:     100010000        Indices: 0     4
Operator 5:     100000100        Indices: 0     6
Operator 6:     101000000        Indices: 0     2
Operator 7:     010000010        Indices: 1     7
Operator 8:     001000001        Indices: 2     8
Operator 9:     000000100        Indices: 6
[5]:
# These operators are ranked from low to high entropy
for i in range(n):
    # Take the ith column of the matrix
    spin_op_i = opt_basis.matrix[:,i]
    print("Entropy of operator", i, ":\t", np.round(data.entropy_of_spin_operator(spin_op_i), 5))
Entropy of operator 0 :  0.25176
Entropy of operator 1 :  0.32138
Entropy of operator 2 :  0.37267
Entropy of operator 3 :  0.37486
Entropy of operator 4 :  0.38776
Entropy of operator 5 :  0.41832
Entropy of operator 6 :  0.44482
Entropy of operator 7 :  0.52134
Entropy of operator 8 :  0.58803

Basis transformation

[6]:
transformed_data = opt_basis.gauge_transform_data(data)

Search for the optimal MCM

[7]:
# The system is small enough to perform an exhaustive search
opt_mcm = mcm_searcher.exhaustive(transformed_data)
opt_mcm.print_details()
MCM contains 9 variables divided into 3 components
Total log-evidence: -3154.42
Component 0 :   100000000        Size: 1         Log-evidence: -228.947
Component 1 :   011000100        Size: 3         Log-evidence: -970.39
Component 2 :   000111011        Size: 5         Log-evidence: -1955.08

Analysis

Log-evidence

[8]:
print("The log-evidence of the complete model: ", transformed_data.log_evidence(MCM(n, "complete")))
print("The log-evidence of the independent model: ", transformed_data.log_evidence(MCM(n, "independent")))

print("The log-evidence of the optimal MCM: ", transformed_data.log_evidence(opt_mcm))
The log-evidence of the complete model:  -3305.546575913697
The log-evidence of the independent model:  -3327.0799458467227
The log-evidence of the optimal MCM:  -3154.421230299753