In [19]:
%pylab inline
from random import gauss, uniform

alpha = .125
EstimatedRTT = 1.0
samples = []
estimates = []
for i in range(100):
    SampleRTT = uniform(-0.5,.5) + 1.5
    EstimatedRTT = (1.0-alpha) * EstimatedRTT + alpha * SampleRTT
    samples.append(SampleRTT)
    estimates.append(EstimatedRTT)


Populating the interactive namespace from numpy and matplotlib

In [20]:
plot(range(100), samples,range(100),estimates)


Out[20]:
[<matplotlib.lines.Line2D at 0x10fc7feb8>,
 <matplotlib.lines.Line2D at 0x10fce4240>]

In [22]:
alpha = .125
beta = 0.25
EstimatedRTT = 1.0
DevRTT = 0.0
samples = []
estimates = []
tointervals = []

for i in range(100):
    SampleRTT = uniform(-0.5,.5) + 1.5
    EstimatedRTT = (1.0-alpha) * EstimatedRTT + alpha * SampleRTT
    DevRTT = (1-beta) * DevRTT + beta * abs(SampleRTT-EstimatedRTT)
    TimeoutInterval = EstimatedRTT + 4 * DevRTT
    samples.append(SampleRTT)
    estimates.append(EstimatedRTT)
    tointervals.append(TimeoutInterval)

plot(range(100), samples,range(100),estimates,range(100),tointervals)


Out[22]:
[<matplotlib.lines.Line2D at 0x10fdad2b0>,
 <matplotlib.lines.Line2D at 0x10fdad5f8>,
 <matplotlib.lines.Line2D at 0x10fdade10>]

In [ ]: