daily pastebin goal
50%
SHARE
TWEET

Untitled

a guest Feb 21st, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from collections import defaultdict
  2.  
  3. import numpy as np
  4.  
  5. n = 10
  6. z = np.random.random(n)
  7. z = z / np.sum(z)
  8.  
  9. total_cnt = 100000
  10. cnts = defaultdict(int)
  11. for i in range(total_cnt):
  12.     u = np.random.uniform(size=n)
  13.     g = -np.log(-np.log(u))
  14.     x = np.argmax(g + np.log(z))
  15.     cnts[x] += 1
  16.    
  17. print(np.var(np.array([cnts[x] for x in cnts.keys()]) / float(total_cnt) - z))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top