Esempio n. 1
0
sim = Simulation()
sim.add("h'=a", 1, plot=True)
sim.add_data(t=t, h=h, plot=True)
sim.params(a=1)
sim.run(0, 12)

# <markdowncell>

# ### Fit the model parameter, $a$
#
# Specifying the prior probability distribution for $a$ as uniform between -10 and 10.

# <codecell>

model = MCMCModel(sim, {'a': [-10, 10]})
model.fit(iter=25000)

# <markdowncell>

# What is the best fit parameter value?

# <codecell>

model.a

# <markdowncell>

# ### Rerun the model

# <codecell>
Esempio n. 2
0
sim=Simulation()
sim.add("h'=a",1,plot=True)
sim.add_data(t=t,h=h,plot=True)
sim.params(a=1)
sim.run(0,12)

# <markdowncell>

# ### Fit the model parameter, $a$
# 
# Specifying the prior probability distribution for $a$ as uniform between -10 and 10.

# <codecell>

model=MCMCModel(sim,{'a':[-10,10]})
model.fit(iter=25000)

# <markdowncell>

# What is the best fit parameter value?

# <codecell>

model.a

# <markdowncell>

# ### Rerun the model

# <codecell>
Esempio n. 3
0
data_t=[0,1,2,3]
data_mouse=[2,5,7,19]

sim=Simulation()                    # get a simulation object

sim.add("mice'=b*mice - d*mice",    # the equations
    2,                            # initial value
    plot=True)                      # display a plot, which is the default

sim.add_data(t=data_t,mice=data_mouse,plot=True)
sim.params(b=1.1,d=0.08)            # specify the parameters
sim.run(5)

# <codecell>

model=MCMCModel(sim,{'b':[0,10]})
model.fit(iter=25000)

# <codecell>

model.b

# <codecell>

sim.run(5)

# <codecell>

model.plot_distributions()

# <codecell>
Esempio n. 4
0
data_mouse = [2, 5, 7, 19]

sim = Simulation()  # get a simulation object

sim.add(
    "mice'=b*mice - d*mice",  # the equations
    2,  # initial value
    plot=True)  # display a plot, which is the default

sim.add_data(t=data_t, mice=data_mouse, plot=True)
sim.params(b=1.1, d=0.08)  # specify the parameters
sim.run(5)

# <codecell>

model = MCMCModel(sim, {'b': [0, 10]})
model.fit(iter=25000)

# <codecell>

model.b

# <codecell>

sim.run(5)

# <codecell>

model.plot_distributions()

# <codecell>
Esempio n. 5
0
sim.add("S'=-beta(t)*(S*I)/N", N, plot=False)
sim.add("E'=-beta(t)*(S*I)/N - (E/invk)", 135, plot=1)
sim.add("I'=(E/invk) - (1/invGamma *I)", 136, plot=1)
sim.add("R'=(1/invGamma*I)", 0, plot=False)
sim.params(N=N, k=1 / 6.3, q=0.1000, invGamma=5.5000, invk=6.3)
sim.functions(beta)
sim.add_data(t=numOfDays, I=numOfCases, plot=1)
sim.run(0, 350)

# <codecell>

model = MCMCModel(
    sim, {
        'beta0': [0, 1],
        'invGamma': [3.5, 10.7],
        'beta1': [0, 1],
        'q': [0, 100],
        'tau': [100, 150],
        'invk': [5, 22]
    })
#model = MCMCModel(sim,{'invGamma':[3.5,10.7],'q':[0,10]})
model.fit(iter=500)
model.plot_distributions()

# <codecell>

Beta0 = model.beta0

# <codecell>

Beta1 = model.beta1