Commit 4dd623fb authored by Andreas Schmidt's avatar Andreas Schmidt

~= improved CDF efficiency

parent 7b509e64
......@@ -25,7 +25,8 @@ def multi_cdf(dfs, config, export=False, file_name="CDF.pdf"):
for df in dfs:
cdf(df[duration], grid=True, ax=ax)
ax.legend(names)
if(idx == 0):
ax.legend(names)
ax.set_xlabel("{} [us]".format(duration))
ax.set_ylabel("CDF")
plt.subplots_adjust(wspace=0.3,hspace=0.3)
......
......@@ -2,18 +2,15 @@ import matplotlib.pyplot as plt
import numpy as np
import math
def cdf(values, grid=False, ax=None):
# empirical CDF
def F(x,data):
return float(len(data[data <= x]))/len(data)
vF = np.vectorize(F, excluded=['data'])
def cdf(values, ax=None, grid=False, **kwargs):
if ax is None:
ax = plt
ax.semilogx(np.sort(values),vF(x=np.sort(values), data=values))
if not "linestyle" in kwargs:
kwargs["linestyle"] = "-"
s = np.sort(values)
ax.semilogx(s, np.searchsorted(s, s, side='right') / len(s), **kwargs)
if grid:
ax.grid()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment