This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[11pt]{article} | |
\usepackage{url} | |
\usepackage{tikz} | |
\usepackage{calc} | |
\reversemarginpar | |
\usepackage[paper=letterpaper, | |
marginparwidth=1in, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
import matplotlib.pyplot as plt | |
def dictplot(D, f, title): | |
plt.figure() | |
values = [v / sum(list(D.values())) for v in list(D.values())] | |
plt.bar(range(len(D)), values, align='center') | |
plt.xticks(range(len(D)), D.keys()) | |
plt.ylabel('Probability') | |
plt.title(title) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# LaTeX Files | |
*.aux | |
*.glo | |
*.idx | |
*.log | |
*.toc | |
*.ist | |
*.acn | |
*.acr | |
*.alg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Sage script for example in blog post. | |
""" | |
class Tandem_Queue(): | |
""" | |
A class for an instance of the tandem_queue | |
""" | |
def __init__(self, c_1, N, c_2, Lambda, mu_1, mu_2, p): | |
self.c_1 = c_1 | |
self.c_2 = c_2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Pure_Nash_Check(A,B,i,j): | |
if i==0: | |
if j==0: | |
if A[0,0]<A[1,0] or B[0,0]<B[0,1]: | |
return False | |
if j==1: | |
if A[0,1]<A[1,1] or B[0,1]<B[0,0]: | |
return False | |
if i==1: | |
if j==0: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interact | |
def _(A=matrix(RDF,3,3,[8,2,0,1,7,2,1,3,6])/10,x_init=("$\pi^{(0)}$",vector([.2,.5,.3]))): | |
x_init = vector(x_init) | |
data = [x_init * (A^i) for i in range(20)] | |
pi = zip(*data) | |
p = line(enumerate(pi[0]),color='red',legend_label='$\pi_1$',thickness=3) | |
p += line(enumerate(pi[1]),color='blue',legend_label='$\pi_2$',thickness=3) | |
p += line(enumerate(pi[2]),color='green',legend_label='$\pi_3$',thickness=3) | |
p.ymax(1) | |
show(p) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interact | |
def _(A=matrix(RDF,[[1,3,1],[5,-2,2],[3,3,4]]),n=("$n$",slider(0,100,1)),Precision=slider(0,10,1,4)): | |
exp_A=exp(A) | |
approx_exp=sum([A^i/factorial(i) for i in range(n+1)]).n(digits=Precision) | |
p=list_plot([(sum([A^i/factorial(i) for i in range(n+1)])-exp(A)).norm(2) for n in range(0,21)]) | |
p.axes_labels(['$n$','$|| e^{A}-\sum_{i=0}^{n}A^{i}/{i!}||_2$']) | |
print "\n" | |
print "Value of approximation for n=%s: \n%s" % (n, approx_exp) | |
print "\n" | |
print "Exact value: \n%s" % exp(A) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in range(10): | |
print i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shortest possible simulation of an MM1 Q (with warmup). Contributors: Geraint, Jason, Vince, Harald and Chris. | |
from random import expovariate | |
lmbda, mu, T, warmup, waits, sample, arrival_time, start_time, end_time = 1, 2, 5000, 1000, [], lambda x: expovariate(x), 0, 0, 0 | |
while end_time < T: | |
arrival_time += sample(lmbda) | |
start_time = max(end_time, arrival_time) | |
end_time = start_time + sample(mu) | |
if arrival_time > warmup: waits.append(start_time - arrival_time) | |
print 'Mean wait: ' + str(sum(waits) / len(waits)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Going to simulate 100 '1st two days of xmas' | |
""" | |
from __future__ import division | |
import random | |
partidges = [] | |
turtle_doves= [] | |
for xmas in range(100): | |
partidges.append(random.choice([0,1,1,1,2])) |
OlderNewer