如何模拟死亡率并将其可视化为随时间消失的点
How to simulate death rate and visualize them as dots disappearing over time
所以,我刚刚使用 scipy 解决了人口死亡率的 ODE 模型,并将其绘制在二维图表中与时间的关系。我认为如果我可以将人口想象成以 ODE 定义的死亡率消失的点,那将会很有趣。有哪些好的 Python 库和 GUI 可以处理这个问题?
添加。信息:
我是如何求解 ODE 的:
import scipy.integrate as spi
import numpy as np
import pylab as pl
L = 1500
alpha = 0.25
sigma = 0.75
TS = 1.0
ND = 120
m = 0.24
mu = 0.06
w = 10000
H0 = 45000 #initial number of hive bees
F0 = 15000 #initial number of forager bees
INPUT = (H0, F0)
def death_rates(INP, t):
Y = np.zeros((2))
V = INP #V[0] = H, V[1] = F
Y[0] = ((L*(V[0]+V[1]))/(w+V[0]+V[1])) - V[0]*(alpha - sigma*(V[1]/(V[0]+V[1]))) - mu*V[0]
Y[1] = V[0]*(alpha - sigma*(V[1]/(V[0]+V[1]))) - m*V[1]
return Y
t_start = 0.0; t_end = ND; t_inc = TS
t_range = np.arange(t_start, t_end+t_inc, t_inc)
RES = spi.odeint(death_rates, INPUT, t_range)
print RES
pl.subplot(311)
pl.plot(RES[:,0], '-g', label='Hive Bees')
pl.xlabel('Time')
pl.ylabel('Hive Bees')
pl.subplot(312)
pl.plot(RES[:,1], '-r', label='Forager Bees')
pl.xlabel('Time')
pl.ylabel('Forager Bees')
pl.show()
生成了下图:
基本上,我想做的是将结果动画化为最初在种群数量 N0 处的点(蜜蜂)不断消失,直到它在种群数量 N1 处稳定下来,例如 60 秒。
Plotly 适用于 Python。此 link 末尾的 "gapminder" 示例与您想要的类似。
向下滚动到最后。
https://plot.ly/python/animations/
这是一个屏幕截图 - 但最好是动画:
如果没有示例数据和关于您想要的内容的更多详细信息,真的无法为您提供更多信息(我可以想象一些与您描述的内容相匹配的内容)。
所以,我刚刚使用 scipy 解决了人口死亡率的 ODE 模型,并将其绘制在二维图表中与时间的关系。我认为如果我可以将人口想象成以 ODE 定义的死亡率消失的点,那将会很有趣。有哪些好的 Python 库和 GUI 可以处理这个问题?
添加。信息:
我是如何求解 ODE 的:
import scipy.integrate as spi
import numpy as np
import pylab as pl
L = 1500
alpha = 0.25
sigma = 0.75
TS = 1.0
ND = 120
m = 0.24
mu = 0.06
w = 10000
H0 = 45000 #initial number of hive bees
F0 = 15000 #initial number of forager bees
INPUT = (H0, F0)
def death_rates(INP, t):
Y = np.zeros((2))
V = INP #V[0] = H, V[1] = F
Y[0] = ((L*(V[0]+V[1]))/(w+V[0]+V[1])) - V[0]*(alpha - sigma*(V[1]/(V[0]+V[1]))) - mu*V[0]
Y[1] = V[0]*(alpha - sigma*(V[1]/(V[0]+V[1]))) - m*V[1]
return Y
t_start = 0.0; t_end = ND; t_inc = TS
t_range = np.arange(t_start, t_end+t_inc, t_inc)
RES = spi.odeint(death_rates, INPUT, t_range)
print RES
pl.subplot(311)
pl.plot(RES[:,0], '-g', label='Hive Bees')
pl.xlabel('Time')
pl.ylabel('Hive Bees')
pl.subplot(312)
pl.plot(RES[:,1], '-r', label='Forager Bees')
pl.xlabel('Time')
pl.ylabel('Forager Bees')
pl.show()
生成了下图:
基本上,我想做的是将结果动画化为最初在种群数量 N0 处的点(蜜蜂)不断消失,直到它在种群数量 N1 处稳定下来,例如 60 秒。
Plotly 适用于 Python。此 link 末尾的 "gapminder" 示例与您想要的类似。
向下滚动到最后。
https://plot.ly/python/animations/
这是一个屏幕截图 - 但最好是动画:
如果没有示例数据和关于您想要的内容的更多详细信息,真的无法为您提供更多信息(我可以想象一些与您描述的内容相匹配的内容)。