Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
- import plotly.graph_objs as go
- import numpy as np
- import csv
- import random
- import matplotlib.pyplot as plt
- w, h = 31, 12;
- aaa = [[0 for x in range(w)] for y in range(h)]
- wszystkie = 0
- data = list(csv.reader(open("us_births_69_88.csv")))
- for i in range(1,373):
- miesiac = int(data[i][0])-1
- dzien = int(data[i][1])-1
- ile = int(data[i][2])
- wszystkie += ile
- aaa[miesiac][dzien] = ile
- wys = 0
- for i in aaa:
- wys = max(max(i), wys)
- d = 373
- def fun():
- while(1):
- pick = random.randrange(wys)
- mies = random.randrange(12)
- dzie = random.randrange(31)
- if aaa[mies][dzie] >= pick:
- return mies*31 + dzie
- def fan():
- l = [0 for i in range(d)]
- for i in range(d+1):
- pick = fun()
- if l[int(pick)] == 1:
- return i
- l[int(pick)] = 1
- return -1
- N=10**5
- ly = [0 for i in range(N)]
- for i in range(N):
- ly[i] = fan()
- plt.hist(ly, bins=range(max(ly)))
- a=3
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement