def exponential_hist(times, a, b, **params):
cutoff = 0.03 # cutoff frequency in ms
if len(times) == 0:
return
bins = np.logspace(a, b, 100)
hist = plt.hist(times, bins=bins, alpha=0.5, **params)
plt.xscale("log")
params.pop("label")
color = params.pop("color")
total = integrate_hist(hist, cutoff)
if sum(times > cutoff) == 0:
return
tmean = times[times > cutoff].mean()
T = np.logspace(a-3, b, 1000)
fT = np.exp(-T/tmean)*T/tmean
fT *= total/integrate_values(T, fT, cutoff)
plt.plot(T, fT, label="exp. fit, mean = %.2f ms" % (tmean,),
color="dark" + color, **params)
plt.xlim(10**a, 10**b)
评论列表
文章目录