-
Notifications
You must be signed in to change notification settings - Fork 0
/
ms_dist_fitter.py
executable file
·66 lines (51 loc) · 2.07 KB
/
ms_dist_fitter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3.11
import pathlib
import pickle
import fitter
import numpy as np
import scipy
DISTS = ['burr', 'burr12', 'alpha', 'beta', 'expon', 'lognorm',
'gamma', 'norm', 'powerlaw', 'exponpow', 'exponnorm', 'logistic']
SIZE = 100_000
BINS = 1000
RATE_HIST_NAME = "func_inv_rate_hist"
DATA_HIST_NAME = "rw_overhead_hist"
def load_emp_hist(name):
with open(f"../slambuc/gen/microservice/hist/{name}.pkl", 'rb') as f:
return pickle.load(f, fix_imports=True)
########################################################################################################################
def get_inv_distribution():
print(RATE_HIST_NAME)
if pathlib.Path(f"hist/{RATE_HIST_NAME}.npy").exists():
with open(f"hist/{RATE_HIST_NAME}.npy", 'rb') as f:
print(">>>> Load inv. rate data from", f.name)
rate_data = np.load(f)
else:
rate_hist = scipy.stats.rv_histogram(load_emp_hist(RATE_HIST_NAME), density=True)
print("histogram:", rate_hist)
rate_data = rate_hist.rvs(size=SIZE)
print("Data size", len(rate_data))
fit = fitter.Fitter(data=rate_data, bins=BINS, distributions=DISTS, timeout=600, density=True)
print("fitter:", fit)
fit.fit(progress=True)
print(fit.summary(Nbest=len(DISTS)))
print(fit.get_best())
def get_rw_distribution():
print(DATA_HIST_NAME)
if pathlib.Path(f"hist/{DATA_HIST_NAME}.npy").exists():
with open(f"hist/{DATA_HIST_NAME}.npy", 'rb') as f:
print(">>>> Load R/W data from", f.name)
data_data = np.load(f)
else:
data_hist = scipy.stats.rv_histogram(load_emp_hist(DATA_HIST_NAME), density=True)
print("histogram:", data_hist)
data_data = data_hist.rvs(size=SIZE)
print("Data size", len(data_data))
fit = fitter.Fitter(data=data_data, bins=BINS, distributions=DISTS, timeout=600, density=True)
print("fitter:", fit)
fit.fit(progress=True)
print(fit.summary(Nbest=len(DISTS)))
print(fit.get_best())
if __name__ == '__main__':
get_inv_distribution()
get_rw_distribution()