Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. ran = range(0, M)
  2.  
  3. def v(d):
  4.     for x in phi:
  5.         t = True
  6.         for y in x:
  7.             if y < 0:
  8.                 t = t and (not d[-y - 1])
  9.             else:
  10.                 t = t and d[y - 1]
  11.             if not t:
  12.                 break
  13.         if not t:
  14.             continue
  15.         else:
  16.             return True
  17.     return False
  18.  
  19. def g(N):
  20.     licz = 0
  21.     for i in range(0, N):
  22.         d = np.random.randint(0, 1 + 1, M)
  23.         d = d < 1
  24.         if v(d):
  25.             licz += 1
  26.     return pow(2, M) * licz / N
  27.  
  28. N = 100
  29. d = 100
  30. ran = range(0, d)
  31.  
  32. w = [ g(N) for i in ran ]
  33.  
  34. plt.hist(w, bins = 10)
  35. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement