Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import division
- import itertools as it
- import numpy as np
- l = input('How many lattices?_')
- m = input('How many markers?_')
- sums = 0
- sumcount = 0
- pos = 1
- neg = -1
- L = list(it.product([-1,1], repeat =l))
- M = range(0,l) # makes a list from 0 to l-1, giving l entries, starting with 0 just like the indices of the lattices.
- Markers = list(it.combinations(M, m))
- i = 0
- j = 0
- k = 0
- while i < len(L):
- Ring = L[i]
- while j < len(Markers):
- while k < 2*len(Ring):
- Marker = Markers[j]
- Ring = list(np.roll(Ring,1))
- for x in Marker:
- t = Ring.pop(x)
- if t < 0:
- Ring.insert(x,pos)
- elif t > 0:
- Ring.insert(x,neg)
- else:
- print('This is why we cant have nice things...')
- sums = sums + abs(sum(Ring))
- sumcount = sumcount + 1
- k = k + 1
- j = j + 1
- k = 0
- i = i + 1
- j = 0
- k = 0
- print 'Average deviation: ', sums/sumcount
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement