Skip to content

Instantly share code, notes, and snippets.

View drvinceknight's full-sized avatar
😀
👍

Vince Knight drvinceknight

😀
👍
View GitHub Profile

Risk Assessment for DjangoCon-Europ 2015

http://2015.djangocon.eu/

Location: Cardiff

Activities associated with arrival and departure at the conference venue

Description - Some foreign visitors may forget that traffic drives on the left in the UK

  • Consequence (scale: 1 to 10) => Personal Injury: 8
from matplotlib import pyplot as plt
plt.xkcd()
ymin = -25
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
plt.xticks([])
This project will introduce the selected student to some neat areas of mathematics. Notably: game theory and queueing theory!
The latter of these studies the interaction of strategic decision makers and the former looks at the study of waiting in a queue. This area of mathematics has many applications including the study of the National Healthcare System.
In this project the student will learn some novel theoretical mathematics (some of which is not taught till the later years of a mathematics degree) and also write relevant computer code and/or analyse of data.
from __future__ import division
import matplotlib.pyplot as plt
def plot(data):
row_player = [len([strategy for strategy in [row[0] for row in data[:round]] if strategy=='H'])/(round + 1) for round in range(len(data))]
column_player = [len([strategy for strategy in [row[1] for row in data[:round]] if strategy=='H'])/(round + 1) for round in range(len(data))]
plt.figure()
plt.scatter(range(len(row_player)), row_player, label='Player 1 probability of playing H')
plt.scatter(range(len(column_player)), column_player, color='red', label='Player 2 probability of playing T')
plt.plot([0, len(row_player)], [.5, .5], color='green', linestyle='-')
from __future__ import division
import matplotlib.pyplot as plt
def plot(data):
row_player = [len([strategy for strategy in [row[0] for row in data[:round]] if strategy=='H'])/(round + 1) for round in range(len(data))]
column_player = [len([strategy for strategy in [row[1] for row in data[:round]] if strategy=='H'])/(round + 1) for round in range(len(data))]
plt.figure()
plt.scatter(range(len(row_player)), row_player, label='Player 1 probability of playing H')
plt.scatter(range(len(column_player)), column_player, color='red', label='Player 2 probability of playing T')
plt.plot([0, len(row_player)], [.5, .5], color='green', linestyle='-')
def simple_sum(a, b):
return a + b
print simple_sum(5, 3) # You should get 8
"""
Quick script and data to analyse game played in class against a random strategy
The variable 'student_data' is a list composed of lists of strategies recorded by
players in class against a computer player a series of 3 mixed strategies:
- (.2, .8)
- (.9, .1)
- (1/3, 2/3)
\documentclass[tikz]{standalone}
\usepackage{tikz,amsmath}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
% First round
% Duel 1
\node (Sally) at (0,0) {Sally};
\node at ($(Sally) + (0,-.5)$) [blue] {P,P,L,R,Sc};
"""
Script to analyse the rock paper scissors lizard tournament I played in class
"""
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')
"""
Quick script to run a Monte Carlo simulation of the effect of utility assumptions for a blog post about the last play in the super bowl
"""
from __future__ import division
class NashEquilibrium:
"""
Class for the Nash Equilibrium (just something to hold data)
"""
def __init__(self, A, B, C, D):