-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
38 lines (30 loc) · 911 Bytes
/
plot.py
File metadata and controls
38 lines (30 loc) · 911 Bytes
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
import os
import numpy as np
import helper
import math
from scipy.optimize import curve_fit
def func(x, a, b):
return a+b*np.log(x)
def func_lin(x, a, b):
exp = -1/2
return a + b*x**exp
def plot():
data = helper.read_list("output/data.txt")
loss = [float(item[0]) for item in data]
y = [float(item[1]) for item in data]
popt, pcov = curve_fit(func, loss, y)
y_plot = func(loss, *popt)
popt_calc, pcov_calc = curve_fit(func_lin, loss, y)
print "C = %s" % popt_calc[1]
format(helper.plt)
d1 = helper.plt.scatter(loss, y, label='Reno')
d2 = helper.plt.plot(loss, y_plot,
label='Model, C = %f' % popt_calc[1], linestyle='dashed')
helper.plt.legend()
helper.plt.savefig("figure_reproduced.png")
def format(plot):
plot.xlabel("loss (%)")
plot.ylabel("BW*RTT/MSS")
plot.xscale('log')
if __name__ == '__main__':
plot()