Created
December 12, 2012 21:47
-
-
Save saltavenger/4271932 to your computer and use it in GitHub Desktop.
not working
This file contains 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 simulationWithoutDrug(numViruses, maxPop, maxBirthProb, clearProb, | |
numTrials): | |
""" | |
Run the simulation and plot the graph for problem 3 (no drugs are used, | |
viruses do not have any drug resistance). | |
For each of numTrials trial, instantiates a patient, runs a simulation | |
for 300 timesteps, and plots the average virus population size as a | |
function of time. | |
numViruses: number of SimpleVirus to create for patient (an integer) | |
maxPop: maximum virus population for patient (an integer) | |
maxBirthProb: Maximum reproduction probability (a float between 0-1) | |
clearProb: Maximum clearance probability (a float between 0-1) | |
numTrials: number of simulation runs to execute (an integer) | |
""" | |
avgList= [] | |
timestep = 0 | |
for i in range(numTrials): | |
virusPop = [] | |
for i in range(numViruses): | |
virusPop.append(SimpleVirus(maxBirthProb, clearProb)) | |
Ali = Patient(virusPop, maxPop) | |
for i in range(300): | |
virusPop.append(int(Ali.update())) | |
print virusPop | |
total= 0 | |
for i in virusPop: | |
total += i | |
average = total/len(viruses) | |
avgList.append[float(average)] | |
pylab.figure(1) | |
pylab.plot(avgList) | |
pylab.xlabel('Time Steps') | |
pylab.ylabel('Average Virus Population') | |
pylab.title('SimpleVirus Simulation') | |
pylab.legend(loc = 'best') | |
pylab.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment