Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Load the inferred values:
- a_new = np.loadtxt('anew.txt')
- #print a_new
- j_old = 0.01
- count = 0
- Nq = 2000
- ## Decimation algorithm:
- ## Null couplings:
- J0 = a_new[np.where(a_new <= -0.03)]
- #Decimate the small values:
- J0s = a_new[np.where(a_new <= -0.03)] = 0.0
- n1 = (a_new == 0).sum() # count the zero values
- print n1
- # Non-zero couplings:
- J2 = a_new[np.where(a_new >= -0.03)]
- j2s = np.count_nonzero(a_new)
- #print J2,j2s
- for i in range(500):
- j0s = 0.0
- #maximize:
- x = np.random.uniform(0.2,0.4)
- Lmax = np.log(1-x)*(s2[j1])-((1-x)*sum1/1-np.power((1-x), sum1))*(np.log(1-x)*s2[j1])
- #print Lmax
- #infer the couplings:
- jnew = j_old + (rate*Lmax[:,44])
- #sort inferred couplings by absolute values:
- jabs = np.absolute(jnew)
- #print jabs
- j1s = jabs[np.where(jabs < 0.0009)] = 0.0
- #print jabs
- #move the least couplings from j1s to j0s:
- #
- jabs1 = np.extract(j1s == 0.0, j1s) #j1s ==0.0
- jabs2 = np.extract(jabs >= 0.0009, jabs)
- #print jabs2
- if(np.any(jabs != 0.0)):
- count = count+1
- print count, jabs, j1s
- #Nq = (100*99)/2
- #x1 = (Nq - jj)/ Nq # jj: fraction of non-decimated couplings:
- #x1 = np.arange(1,0,-0.01)
- x1 = (Nq-j1s)/Nq
- xs = (Nq-count)/2 # of decimated couplings:
- #print x1
- #define the tilted likelihood:
- tplf = L1[:,44]-x1*Lmax[:,44]-(1-x1)*(-(np.log(2)))
- #print tplf, x1, Nq, j1s
- #print tplf, xs, x1
Add Comment
Please, Sign In to add comment