Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikbern/a9dfef6ff1834ccfac8dc58a9d80d019 to your computer and use it in GitHub Desktop.
Save erikbern/a9dfef6ff1834ccfac8dc58a9d80d019 to your computer and use it in GitHub Desktop.
import numpy
from matplotlib import pyplot
import seaborn
p = numpy.logspace(-6, 0, 50)
pyplot.figure(figsize=(10, 5))
for k in [1, 3, 10, 30, 100, 300, 1000]:
Z = (p * k**2 + (1 - p)) / (p * k + (1 - p))
pyplot.plot(p, Z, label='Delay factor %d for train problem' % k)
pyplot.xscale('log')
pyplot.yscale('log')
pyplot.title('Average time you have to wait given that train problems with some probability and magnitude')
pyplot.xlabel('Probability of train problem')
pyplot.ylabel('Average time you have to wait compared to baseline')
pyplot.legend(loc=2)
pyplot.savefig('train_problems.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment