python - 如何模拟死亡率并将其可视化为随着时间推移而消失的点

标签 python visualization simulation

所以,我刚刚使用 scipy 求解了人口死亡率的 ODE 模型,并将其绘制在随时间变化的二维图中。我认为如果我能将人口可视化为以常微分方程定义的死亡率消失的点,那会很有趣。有哪些好的 Python 库和 GUI 可以处理这个问题?

添加。信息:

我如何求解常微分方程:

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()

生成了以下图表: 2D plot of the population decline

基本上,我想要做的是将结果动画化为最初在种群数量 N0 处的点(蜜蜂)不断消失,直到在 60 秒的时间内在种群 N1 处达到稳定状态。

最佳答案

Plotly 可与 Python 配合使用。此链接末尾的“gapminder”示例与您想要的类似。

向下滚动到末尾。

https://plot.ly/python/animations/

这是一个屏幕截图 - 但最好是动画:

enter image description here

如果没有示例数据和有关您想要的内容的更多详细信息,就无法真正为您提供更多信息(我可以想象一些与您所描述的内容相匹配的内容)。

关于python - 如何模拟死亡率并将其可视化为随着时间推移而消失的点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43836406/

相关文章:

java - 某处是否有动态词/标签云 Java API?

python - Matplotlib - 使用 matshow 在多行之间没有空格

c - 使用 QEMU 作为外部翻译库

simulation - 量子计算机的软件模拟

python - 在矩形联合中找到洞?

Python 如何将 8 位 ASCII 字符串转换为 16 位 Unicode

python - Flask-WTForms 测试(使用 py.test)

python - 我无法将我在 Seaborn 中的线图的 xticks 设置为相应小时的值

Python 2.7.2 在 OSX 上搁置失败

r - 生成移位的 t 分布数和非中心参数?