CSCS530 Winter 2015

Complex Systems 530 - Computer Modeling of Complex Systems (Winter 2015)

View this repository on NBViewer

In [6]:
#Class Program on 2015-01-16
import numpy
import matplotlib.pyplot as plt

initialNumPeople = 10 #inital number of people
barCapacity = 80
maxExitRatePerTimeStep = 5
minExitRatePerTimeStep = 0
maxTimeStep = 100
currentTime = 0
peopleList = []


#Our goal is to measure how many people are in the bar across timesteps

#create model that counts/changes number of people in the bar
#condition to stop when we reach max timestep
#Can simulate random number of people entering bar at some probability that changes over time
#based on amount over/under capacity, change probability of going to bar the next timestep

while currentTime < maxTimeStep:
    if initialNumPeople >= barCapacity:
        enteringPeeps = 0 #no one enters the bar if it is at full capacity
    else:
        enteringPeeps = int(numpy.random.normal(5,1))
    exitingPeeps = int(numpy.random.uniform(minExitRatePerTimeStep, maxExitRatePerTimeStep))
    if exitingPeeps > initialNumPeople+enteringPeeps:
        exitingPeeps = 0
    initialNumPeople = initialNumPeople + enteringPeeps - exitingPeeps        
    peopleList.append(initialNumPeople)
    currentTime +=1
    
%matplotlib inline

f = plt.figure()
plt.plot(peopleList)
plt.xlabel('TimeStep')
plt.ylabel('Number of People in the Bar')
plt.title('Rockstar CSCS530 1st Program Yay')
Out[6]:
<matplotlib.text.Text at 0x1046b42d0>
In [ ]:
for x in xrange(0,10):
    print x