Guest User

Untitled

a guest
Dec 15th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. # Load the inferred values:
  2. a_new = np.loadtxt('anew.txt')
  3. #print a_new
  4. j_old = 0.01
  5. count = 0
  6. Nq = 2000
  7. ## Decimation algorithm:
  8. ## Null couplings:
  9. J0 = a_new[np.where(a_new <= -0.03)]
  10. #Decimate the small values:
  11. J0s = a_new[np.where(a_new <= -0.03)] = 0.0
  12. n1 = (a_new == 0).sum() # count the zero values
  13. print n1
  14. # Non-zero couplings:
  15. J2 = a_new[np.where(a_new >= -0.03)]
  16. j2s = np.count_nonzero(a_new)
  17. #print J2,j2s
  18. for i in range(500):
  19. j0s = 0.0
  20. #maximize:
  21. x = np.random.uniform(0.2,0.4)
  22. Lmax = np.log(1-x)*(s2[j1])-((1-x)*sum1/1-np.power((1-x), sum1))*(np.log(1-x)*s2[j1])
  23. #print Lmax
  24. #infer the couplings:
  25. jnew = j_old + (rate*Lmax[:,44])
  26. #sort inferred couplings by absolute values:
  27. jabs = np.absolute(jnew)
  28. #print jabs
  29. j1s = jabs[np.where(jabs < 0.0009)] = 0.0
  30. #print jabs
  31. #move the least couplings from j1s to j0s:
  32. #
  33. jabs1 = np.extract(j1s == 0.0, j1s) #j1s ==0.0
  34. jabs2 = np.extract(jabs >= 0.0009, jabs)
  35. #print jabs2
  36. if(np.any(jabs != 0.0)):
  37. count = count+1
  38. print count, jabs, j1s
  39. #Nq = (100*99)/2
  40. #x1 = (Nq - jj)/ Nq # jj: fraction of non-decimated couplings:
  41. #x1 = np.arange(1,0,-0.01)
  42. x1 = (Nq-j1s)/Nq
  43. xs = (Nq-count)/2 # of decimated couplings:
  44. #print x1
  45. #define the tilted likelihood:
  46. tplf = L1[:,44]-x1*Lmax[:,44]-(1-x1)*(-(np.log(2)))
  47. #print tplf, x1, Nq, j1s
  48. #print tplf, xs, x1
Add Comment
Please, Sign In to add comment