我写了一个python程序,它基本上采用包含Web服务器ping响应的86400行的文本文件.我从每一行中提取往返行程并将其添加到名为roundtriptimes的数组中.然后我对数组进行排序,现在希望能够使用matplotlib绘制数据的CDF.我目前的代码如下:
import re
import numpy as np
import matplotlib.pyplot as plt
ping = open("pingresponse.txt")
rawping = ping.read()
roundtriptimes = re.findall(r'time=(\d+.\d+)', rawping)
roundtriptimes[:] = [float(x) for x in roundtriptimes]
sortedtime = np.sort(roundtriptimes)
p = 1. * np.arange(len(roundtriptimes))/(len(roundtriptimes) - 1)
plt.plot(sortedtime, p)
plt.show()
我已经阅读了关于这个主题的其他帖子,但他们的解决方案似乎都不适合我.我想获得一个如下所示的CDF情节:
但相反,我得到了一个急剧增加的斜率.我只是想确保我所做的CDF计算是正确的.
任何帮助将不胜感激.
解决方法:
在评论中回答:
This looks right. Not particularly useful, but not abnormal either. You have a few packets with big delays that push the upper limit to 600 ms. – Sato Katsura Oct 5 at 7:38
标签:python,statistics,plotting
来源: https://codeday.me/bug/20190815/1660362.html