示例#1
0
def main():
    for p1 in p1_range:
        for p3 in p3_range:
            # create the simulation object
            sim = SIRS(p1=p1,
                       p2=0.5,
                       p3=p3,
                       create_anim=False,
                       x_dim=20,
                       y_dim=20)
            sim.count_infected_sites = True
            print(p1, p3)
            inf_array = sim.simulate()
            avg = np.mean(inf_array) / float(sim.sweep)
            susc = np.var(inf_array) / float(sim.sweep)
            with open(out_file, 'a+') as f:
                f.write(' '.join(
                    (str(p1), str(p3), str(avg), str(susc), '\n')))
示例#2
0
def main():
    for frac in frac_range:
        print(frac)
        # create the simulation object
        sim = SIRS(p1=0.5,
                   p2=0.5,
                   p3=0.5,
                   create_anim=False,
                   immune_frac=frac,
                   x_dim=20,
                   y_dim=20)
        sim.count_infected_sites = True
        inf_array = sim.simulate()
        #inf_array_sq = [val*val for val in inf_array]
        avg = np.mean(inf_array) / float(sim.sweep)
        susc = np.std(inf_array) / float(sim.sweep)
        with open(out_file, 'a+') as f:
            f.write(' '.join((str(frac), str(avg), '\n')))