SHARE
TWEET

Untitled

a guest Nov 17th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
  2. import plotly.graph_objs as go
  3. import numpy as np
  4. import csv
  5. import random
  6. import matplotlib.pyplot as plt
  7.  
  8. w, h = 31, 12;
  9. aaa = [[0 for x in range(w)] for y in range(h)]
  10.  
  11.  
  12. wszystkie = 0
  13. data = list(csv.reader(open("us_births_69_88.csv")))
  14.  
  15. for i in range(1,373):
  16.     miesiac = int(data[i][0])-1
  17.     dzien = int(data[i][1])-1
  18.     ile = int(data[i][2])
  19.     wszystkie += ile
  20.     aaa[miesiac][dzien] = ile
  21.    
  22. wys = 0
  23. for i in aaa:
  24.     wys = max(max(i), wys)
  25.    
  26. d = 373
  27.  
  28. def fun():
  29.     while(1):
  30.         pick = random.randrange(wys)
  31.         mies = random.randrange(12)
  32.         dzie = random.randrange(31)
  33.         if aaa[mies][dzie] >= pick:
  34.             return mies*31 + dzie
  35.        
  36. def fan():
  37.     l = [0 for i in range(d)]
  38.     for i in range(d+1):
  39.         pick = fun()
  40.         if l[int(pick)] == 1:
  41.             return i
  42.         l[int(pick)] = 1
  43.     return -1
  44.  
  45. N=10**5
  46. ly = [0 for i in range(N)]
  47. for i in range(N):
  48.     ly[i] = fan()
  49.  
  50. plt.hist(ly, bins=range(max(ly)))
  51. a=3
  52. plt.show()
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