Comcast Speeds

In [1]:
%pylab
%matplotlib inline
from dateutil.parser import parse
# 
import os
import numpy

csv_file="../files/files/SpeedTests.csv"
#
assert(os.path.exists(csv_file))
# https://docs.python.org/3/library/csv.html#csv.reader
import csv
#
class speedtest(object):
    def __init__(self,row_list):
        self.date=parse(row_list[0])
        self.ping=float(row_list[1])
        self.dl=float(row_list[2])
        self.ul=float(row_list[3])
    def __repr__(self):
        return "speedtest<{},{},{},{}>".format(self.date, self.ping, self.ul, self.ul)

speedtests=list()
# https://docs.python.org/3/library/csv.html#csv.reader
import csv
with open(csv_file, newline='') as csvfile:
    spamreader = csv.reader(csvfile, delimiter=',', quotechar='"')
    for row in spamreader:w.
        speedtests.append(speedtest(row))
# 
t0=float(speedtests[0].date.strftime("%s"))
days=[(float(t.date.strftime("%s"))-t0) for t in speedtests]
dl=[test.dl for test in speedtests]
ping=[test.ping for test in speedtests]
ul=[test.ul for test in speedtests]
import numpy
days=numpy.array(days)
dl=numpy.array(dl)
ul=numpy.array(ul)
ping=numpy.array(ping)
Using matplotlib backend: TkAgg
Populating the interactive namespace from numpy and matplotlib
In [26]:
days=[(float(t.date.strftime("%s"))-t0)/(24*3600) for t in speedtests]
figure(figsize=(20,10))
plot(days,dl,days,ul)
plt.xlim(0,200)
xlabel("Monitor Days")
ylabel(r"$\frac{Mb}{s}$")
legend({'Download (Mb/s)','Upload (Mb/s)'})
title("200 days of Comcast")
Out[26]:
<matplotlib.text.Text at 0x8177482b0>
In [3]:
max(dl)
max(ul)
Out[3]:
4.79
In [28]:
n, bins, patches = plt.hist(dl, 50, normed=1, facecolor='green', alpha=0.75)
xlabel("Download Speed (Mb/s)")
ylabel("Probability")
title("Download Speed Distribution")
Out[28]:
<matplotlib.text.Text at 0x8176ee278>
In [5]:
bins[numpy.where(max(n)==n)[0][0]]
Out[5]:
16.924399999999999
In [33]:
n, bins, patches = plt.hist(ul, 50, normed=1, facecolor='green', alpha=.75)
xlabel("Upload Speed (Mb/s)")
ylabel("Probability")
title("Download Speed Distribution")
bins[numpy.where(max(n)==n)[0][0]]
Out[33]:
2.2991999999999999
In [34]:
start_idx=numpy.where(numpy.array(days)>38.5)[0][0]
end_idx=numpy.where(numpy.array(days)<39)[0][-1]
plot(days[start_idx:end_idx],dl[start_idx:end_idx])
print(speedtests[start_idx])
print(speedtests[end_idx])
speedtest<2015-08-21 11:52:32,36.702,4.66,4.66>
speedtest<2015-08-21 23:26:36,29.625,2.34,2.34>
In [37]:
n, bins, patches = plt.hist(ping[numpy.where(ping<1000)[0]], 50, normed=1, facecolor='green', alpha=0.75)
xlabel("Ping (ms)")
ylabel("Probability")
title("Pings (<1000 ms)")
Out[37]:
<matplotlib.text.Text at 0x819269860>
In [38]:
n, bins, patches = plt.hist(ping[numpy.where(ping<60)[0]], 50, normed=1, facecolor='green', alpha=0.75)
xlabel("Ping (ms)")
ylabel("Probability")
title("Pings (<60 ms)")
Out[38]:
<matplotlib.text.Text at 0x81d85af98>