コード例 #1
0
sim.add(" x'=r2*x*(1-x/K2) ", 1, plot=1)
sim.params(r=2, K=50, r2=3, K2=50)
sim.run(0, 20)

# ## adding some data

# In[31]:

t_data = array([7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84], float)
h_data = array([
    17.93, 36.36, 67.76, 98.10, 131, 169.5, 205.5, 228.3, 247.1, 250.5, 253.8,
    254.5
])

sim = Simulation()
sim.figsize = (6, 4)
sim.add(" y'=r*y*(1-y/K) ", 1, plot=True)
sim.params(r=.2, K=270)
sim.add_data(t=t_data, y=h_data, plot=True)
sim.run(0, 100)

# In[35]:

model = MCMCModel(sim, r=Uniform(0, 1), K=Uniform(100, 400))

# In[36]:

model.run_mcmc(500)

# In[37]:
コード例 #2
0
# <codecell>

x,y=sim.t,sim.mice
plot(x,y,'r--')
xlabel('Days')
ylabel('Number of Mice')

# <markdowncell>

# ## Predator-Prey Dynamics

# <codecell>

sim=Simulation()
sim.figsize=(20,5)

sim.add("deer' = r*deer*(1-deer/K)-c*deer*wolf",
                initial_value=350,
                plot=True)

sim.add("wolf' = -Wd*wolf+D*deer*wolf",
                initial_value=50,
                plot=True)

sim.params(r=0.25,D=0.001,c=0.005,Wd=0.3,K=1e500)

print sim.equations()
sim.run(0,500)

# fig=sim.figures[0]
コード例 #3
0
from pylab import plot, xlabel, ylabel

# In[6]:

x, y = sim.t, sim.mice
plot(x, y, 'r--')
xlabel('Days')
ylabel('Number of Mice')

# ## Predator-Prey Dynamics

# In[8]:

sim = Simulation()
sim.figsize = (20, 5)

sim.add("deer' = r*deer*(1-deer/K)-c*deer*wolf", initial_value=350, plot=True)

sim.add("wolf' = -Wd*wolf+D*deer*wolf", initial_value=50, plot=True)

sim.params(r=0.25, D=0.001, c=0.005, Wd=0.3, K=1e500)

print(sim.equations())
sim.run(0, 500)

# fig=sim.figures[0]
# fig.savefig('predprey_dynamics1.pdf')
# fig.savefig('predprey_dynamics1.png')

# fig=sim.figures[1]