blob: 564e027a0f0fb1c6802f7f16a18e48583da9eca8 [file] [log] [blame]
koder aka kdanilovda45e882015-04-06 02:24:42 +03001import sys
2import collections
3
4import scipy.stats as stats
5import matplotlib.mlab as mlab
6import matplotlib.pyplot as plt
7
8from data_stat import med_dev, round_deviation
9from data_stat import read_data_agent_result
10
11data = read_data_agent_result(sys.argv[1])
12
13# for run in data:
14# for name, numbers in run['res'].items():
15# # med, dev = round_deviation(med_dev(numbers['iops']))
16# # print name, med, '~', dev
17# distr = collections.defaultdict(lambda: 0.0)
18# for i in numbers['iops']:
19# distr[i] += 1
20
21# print name
22# for key, val in sorted(distr.items()):
23# print " ", key, val
24# print
25
26
27
28# # example data
29# mu = 100 # mean of distribution
30# sigma = 15 # standard deviation of distribution
31# x = mu + sigma * np.random.randn(10000)
32
33x = data[0]['res'][sys.argv[2]]['iops']
34# mu, sigma = med_dev(x)
35# print mu, sigma
36
37# med_sz = 1
38# x2 = x[:len(x) // med_sz * med_sz]
39# x2 = [sum(vals) / len(vals) for vals in zip(*[x2[i::med_sz]
40# for i in range(med_sz)])]
41
42mu, sigma = med_dev(x)
43print mu, sigma
44print stats.normaltest(x)
45
46num_bins = 20
47# the histogram of the data
48n, bins, patches = plt.hist(x, num_bins, normed=1, facecolor='green', alpha=0.5)
49# add a 'best fit' line
50
51y = mlab.normpdf(bins, mu, sigma)
52plt.plot(bins, y, 'r--')
53
54plt.xlabel('Smarts')
55plt.ylabel('Probability')
koder aka kdanilovb896f692015-04-07 14:57:55 +030056plt.title(r'Histogram of IQ: $\mu={}$, $\sigma={}$'.format(int(mu), int(sigma)))
koder aka kdanilovda45e882015-04-06 02:24:42 +030057
58# Tweak spacing to prevent clipping of ylabel
59plt.subplots_adjust(left=0.15)
60plt.show()