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
import numpy as np | |
def calculate_q(k): | |
''' | |
Use a numerical root finder to determine q from the equation | |
q = exp(k*(q-1)). | |
''' | |
from scipy.optimize import root | |
return root(lambda q: q - np.exp(k * (q - 1)), 0).x[0] | |
import matplotlib.pyplot as plt |
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
import matplotlib | |
matplotlib.use('TkAgg') | |
from pylab import * | |
import networkx as nx | |
import numpy.random as rd | |
n = 15 #number of nodes | |
k = 3 # number of connections per node, to make (will increase as edges are added from each node) | |
def initialize(): |
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
import matplotlib | |
matplotlib.use('TkAgg') | |
from pylab import * | |
import networkx as nx | |
import random as rd | |
n = 30 # number of nodes | |
#k = 4 # number of neighbors of each node | |
def initialize(): |
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
#pull version | |
import matplotlib | |
matplotlib.use('TkAgg') | |
from pylab import * | |
import networkx as nx | |
import random as rd | |
import numpy as np | |
def initialize(): |
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
import numpy as np | |
import random as rd | |
import matplotlib.pyplot as plt | |
class TrafficSimulation(): | |
def __init__(self, road_length, density, max_velocity, prob_slow, repetitions): | |
self.road_length = road_length | |
self.density = density | |
self.max_velocity = max_velocity |
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
import numpy as np | |
import random as rd | |
class TrafficSimulation(): | |
def __init__(self, road_length, density, max_velocity, prob_slow): | |
self.road_length = road_length | |
self.density = density | |
self.max_velocity = max_velocity | |
self.prob_slow = prob_slow |
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
import matplotlib | |
matplotlib.use('TkAgg') | |
import pylab as PL | |
import random as RD | |
import scipy as SP | |
import numpy as np | |
RD.seed() |
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
# Simple CA simulator in Python | |
# | |
# *** Hosts & Pathogens *** | |
# | |
# Copyright 2008-2012 Hiroki Sayama | |
# sayama@binghamton.edu | |
# Modified to run with Python 3 | |
import matplotlib |
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
#Exercise 11.3 | |
import matplotlib | |
import fractions | |
from fractions import * | |
matplotlib.use('TkAgg') | |
from pylab import * | |
n = 100 # size of space: n x n | |
p = 0.1 # probability of initially panicky individuals |
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
import random | |
from random import randint, choice | |
import numpy as np | |
import itertools | |
random.seed(1) | |
class Passenger(): | |
def __init__(self, desired_floor = 0, current_floor = 0): |