Skip to content

Instantly share code, notes, and snippets.

View geraintpalmer's full-sized avatar

Geraint Palmer geraintpalmer

View GitHub Profile
import random
import copy
alphabet = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
scrambled_alphabet = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
random.seed(0)
random.shuffle(scrambled_alphabet)
original_rotor1 = [(s, a) for a, s in zip(alphabet, scrambled_alphabet)]
random.shuffle(scrambled_alphabet)
original_rotor2 = [(s, a) for a, s in zip(alphabet, scrambled_alphabet)]
print('this is a test')
@geraintpalmer
geraintpalmer / royals.ipynb
Created February 12, 2019 20:50
Create Timeline of English Royals
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Create a new Simulation class that inherits from the ciw.Simulation
# class. Has all the attributes and methods of the original class, but
# we can add a new method, "simulate_until_max_customers".
class Simulation(ciw.Simulation):
def simulate_until_max_customers(self, max_customers):
"""
Runs the simulation until max_customers have finished reached the Exit Node.
"""
self.nodes[0].update_next_event_date()
@geraintpalmer
geraintpalmer / lognormal_hist.py
Created January 6, 2016 10:50
Updating Histogram with Matplotlib
from __future__ import division
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import random
import math
def lognormal_cdf(x, m, s):
x1 = x[0]
x2 = x[1]
inner1 = (math.log(x1) - m)/(s*math.sqrt(2))