# isinglaw.py -- exact comparison of the real glows of the real Hadamard matrices in the folder matrices. For H of # order N, and a,b uniform on {-1,1}^N, conditional on b the glow Omega = is a sum of independent symmetric signs # with coefficients the numbers |(Hb)_j|, so its law is determined by the histogram, over the vectors b with b_1 = 1, of # the sorted lists of the numbers |(Hb)_j|. We compute these histograms exactly, by enumerating the 2^(N-1) vectors b, # and compare them for the matrices of the same order. Usage: python3 isinglaw.py import numpy as np, glob from collections import Counter def histogram(H): N=len(H); hist=Counter(); chunk=1<>np.arange(N-1))&1,-1,1) B=np.hstack([np.ones((chunk,1),dtype=np.int64),B]) L=np.sort(np.abs(B@H.T),axis=1) rows,counts=np.unique(L,axis=0,return_counts=True) for r,c in zip(rows,counts): hist[tuple(r.tolist())]+=int(c) return hist by_order={} for f in sorted(glob.glob('matrices/had*_*.txt')): name=f.split('/')[-1][:-4]; H=np.rint(np.loadtxt(f)).astype(np.int64); N=len(H) h=histogram(H); by_order.setdefault(N,[]).append((name,h)) print("%s: %d distinct lists |Hb|"%(name,len(h)),flush=True) for N,lst in by_order.items(): classes=[] for name,h in lst: for c in classes: if c[1]==h: c[0].append(name); break else: classes.append(([name],h)) print("order %d: matrices with the same real glow: %s"%(N,[c[0] for c in classes]))