Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def PDF(size):
- b = np.random.randn(size)
- J = np.random.randn(size, size)
- density_func = np.zeros(2**size)
- states = dec2bin(2**size)
- for i in range(2**size):
- density_func[i] = np.exp((np.dot(b, states[i,:]) + np.dot(np.dot(states[i],J),states[i])))
- Z = np.sum(density_func)
- density_func = density_func / Z
- return density_func
- def bitfield(n,size):
- x = [int(x) for x in bin(n) [ 2 :]]
- x = [0] * (size - len(x)) + x
- return x
- def dec2bin(size):
- states = []
- for i in range(size):
- binary = bitfield(i, int(np.sqrt(size)))
- states.append(binary)
- return np.array(states)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement