6.00.2x-pset3.py
def simulationWithoutDrug(numViruses, maxPop, maxBirthProb, clearProb,
                          numTrials):
    """
    Run the simulation and plot the graph when no drugs are used and
    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)
    """
    numTimesteps = 300
    virusPopulationPerTrial = {x: () for x in range(numTimesteps)}
    for trial in range(numTrials):
        # Line bellow broken to comply with pep8
        viruses = [SimpleVirus(maxBirthProb, clearProb)
                   for x in range(numViruses)]
        patient = Patient(viruses, maxPop)
        for timestep in range(numTimesteps):
            patient.update()
            virusPopulationPerTrial[timestep] += (patient.getTotalPop(),)
    avgVirusPopulation = {}
    for timestep in virusPopulationPerTrial:
        # Line bellow broken to comply with pep8
        avgVirusPopulation[timestep] = (
                sum(virusPopulationPerTrial[timestep]) /
                len(virusPopulationPerTrial[timestep])
        )
    pylab.plot(list(avgVirusPopulation.values()), label="SimpleVirus")
    pylab.title("SimpleVirus simulation")
    pylab.xlabel("Time Steps")
    pylab.ylabel("Average Virus Population")
    pylab.legend(loc="best")
    pylab.show()

    Run the simulation and plot the graph when no drugs are used and
    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)
    
Run the simulation and plot the graph when no drugs are used and
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.

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)
Run the simulation and plot the graph when no drugs are used and 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 . 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 )
def simulationWithoutDrug(numViruses, maxPop, maxBirthProb, clearProb,
                          numTrials):
    numTimesteps = 300
    virusPopulationPerTrial = {x: () for x in range(numTimesteps)}
    for trial in range(numTrials):
        viruses = [SimpleVirus(maxBirthProb, clearProb)
                   for x in range(numViruses)]
        patient = Patient(viruses, maxPop)
        for timestep in range(numTimesteps):
            patient.update()
            virusPopulationPerTrial[timestep] += (patient.getTotalPop(),)
    avgVirusPopulation = {}
    for timestep in virusPopulationPerTrial:
        avgVirusPopulation[timestep] = (
                sum(virusPopulationPerTrial[timestep]) /
                len(virusPopulationPerTrial[timestep])
        )
    pylab.plot(list(avgVirusPopulation.values()), label="SimpleVirus")
    pylab.title("SimpleVirus simulation")
    pylab.xlabel("Time Steps")
    pylab.ylabel("Average Virus Population")
    pylab.legend(loc="best")
    pylab.show()
def simulationWithoutDrug ( numViruses , maxPop , maxBirthProb , clearProb , numTrials ) : numTimesteps = 300 virusPopulationPerTrial = { x : ( ) for x in range ( numTimesteps ) } for trial in range ( numTrials ) : viruses = [ SimpleVirus ( maxBirthProb , clearProb ) for x in range ( numViruses ) ] patient = Patient ( viruses , maxPop ) for timestep in range ( numTimesteps ) : patient . update ( ) virusPopulationPerTrial [ timestep ] += ( patient . getTotalPop ( ) , ) avgVirusPopulation = { } for timestep in virusPopulationPerTrial : avgVirusPopulation [ timestep ] = ( sum ( virusPopulationPerTrial [ timestep ] ) / len ( virusPopulationPerTrial [ timestep ] ) ) pylab . plot ( list ( avgVirusPopulation . values ( ) ) , label = "SimpleVirus" ) pylab . title ( "SimpleVirus simulation" ) pylab . xlabel ( "Time Steps" ) pylab . ylabel ( "Average Virus Population" ) pylab . legend ( loc = "best" ) pylab . show ( )
Run the simulation and plot the graph when no drugs are used and
viruses do not have any drug resistance.
Run the simulation and plot the graph when no drugs are used and viruses do not have any drug resistance .
"""
    Run the simulation and plot the graph when no drugs are used and
    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)
    """ # Line bellow broken to comply with pep8 # Line bellow broken to comply with pep8
numViruses
maxPop
maxBirthProb
clearProb
numTrials