00_benchmarking-theorem.png
benchmarking-theorem.py
butterfly.png
butterflycurve.py
Image may be NSFW.
Clik here to view.
Clik here to view.

""" | |
Haber's Benchamarketing Theorem | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib.font_manager as fm | |
with plt.xkcd(): | |
fig = plt.figure() | |
font = fm.FontProperties(fname='./xkcd-Regular.otf') | |
x = np.linspace(0, 1) | |
yu = x / x | |
yf = 1 - x | |
yr = np.power(yf, 42) | |
ax = fig.add_axes((0.1, 0.32, 0.8, 0.55)) | |
lu = ax.plot(x, yu, 'g', label='utopian') | |
lf = ax.plot(x, yf, 'm', label='fair world') | |
lr = ax.plot(x, yr, 'r', label='real life') | |
plt.legend(loc=(0.72, 0.5), prop=font) | |
plt.ylim(-0.02, 1.02) | |
ax.spines['right'].set_color('none') | |
ax.spines['top'].set_color('none') | |
ax.xaxis.set_ticks_position('none') | |
ax.yaxis.set_ticks_position('none') | |
ax.set_xticklabels([]) | |
ax.set_yticklabels([]) | |
ttl = plt.title('Benchmarking Theorem', fontproperties=font, fontsize=28) | |
ttl.set_y(1.05) | |
plt.ylabel('probability of accuracy', fontproperties=font) | |
fig.text(0.05, 0.28, 'your app', fontproperties=font, size=14) | |
fig.text(0.42, 0.28, 'other apps', fontproperties=font, size=14) | |
fig.text(0.78, 0.28, 'hello_world.c', fontproperties=font, size=14) | |
fig.text(0.03, 0.85, '100%', fontproperties=font, size=14) | |
fig.text(0.05, 0.32, '0%', fontproperties=font, size=14) | |
fig.text(0.03, 0.18, 'The probability that results from a benchmark accurately', fontproperties=font, size=18) | |
fig.text(0.03, 0.13, 'reflect your app is infinitesimal, unless done on it', fontproperties=font, size=18) | |
fig.text(0.66, 0.04, '@itamarhaber /cc @xkcd', fontproperties=font, size=14) | |
# Tweak spacing to prevent clipping of ylabel | |
plt.subplots_adjust(left=0.15) | |
plt.show() |
Image may be NSFW.
Clik here to view.
Clik here to view.

""" | |
Butterfly curve - http://en.wikipedia.org/wiki/Butterfly_curve_%28transcendental%29 | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib.font_manager as fm | |
with plt.xkcd(): | |
fig = plt.figure() | |
font = fm.FontProperties(fname='./xkcd-Regular.otf') | |
t = np.linspace(-5, 5, 420) | |
x = np.sin(t) * (np.exp(np.cos(t)) - 2 * np.cos(4 * t) - np.power(np.sin(t/12), 5)) | |
y = np.cos(t) * (np.exp(np.cos(t)) - 2 * np.cos(4 * t) - np.power(np.sin(t/12), 5)) | |
lc = plt.plot(x, y, 'k', label='chaos') | |
plt.show() | |