gpt4 book ai didi

language-agnostic - 将数学问题转换为离散事件模拟

转载 作者:行者123 更新时间:2023-12-04 07:44:27 27 4
gpt4 key购买 nike

我正在尝试实现 SIR epidemic model .基本上,我理解模型的方式是,在每个时间步,它告诉我们有多少节点被感染以及有多少节点被恢复。我现在正试图将其转换为离散事件模拟,并且有点困惑。

模型一般采用欧拉法求解。现在,当我将其转换为离散事件模拟时,我正在做这样的事情(数字用于清楚起见):

Initialize 100 members
At every time step t,
//Determine how many get infected
for i = 1 to 100
let i pass a message to its neighbors
When the neighbor receives the message from an infected member, it generates a random number and if it is less than beta*(infected/total), where beta is the infection rate, then the member gets infected
Update the count for infected, recovered, susceptible

//Determine how many are recovered
for i = 1 to 100
Generate a random number from a uniform distribution and check if it is less than gamma*infected. If it is, then this member is recovered.
Update the count for infected, recovered, susceptible

我基本上想知道上述方法是否正确。有什么建议吗?

最佳答案

开始时看起来不错,除了在第一个循环中您需要记住只有易感个体会被感染,而对于第二个循环,只有受感染的个体才能恢复。我还相信每个事件的转换概率(从受感染的邻居接收到消息的可能性,受感染的可能正在恢复)不是当前受感染个体数量的函数——它们是常数(我认为你'将“质量效应”概率误导为在一个时间步应用于每个单独的情节——他们没有)。

有点微妙的是你如何做第一个循环(从 SIR 模型对我来说并不明显):我认为你想确定所有“消息”首先然后 哪些会导致易感的转换 -> 感染 - 即两个循环而不是一个 - 因为在这个时间步骤刚刚被感染的个体无法在同一时间步骤中感染其他人在同一时间步骤,但只能在未来;此外,对于在这个时间步刚刚被感染的个人来说,转换感染 -> 恢复是不可能的,所以你必须安排你的循环有点不同!

考虑用两个“状态”属性对每个个体进行建模:

-- nummsgs, number of "messages" received this time step
-- compartment (susceptible, infected or recovered)

以及一组固定的邻居。那么:

for each individual:
if individual.compartment != infected:
continue
for each neighbor of the individual:
neighbor.nummsgs += 1
if (random number says so):
individual.compartment = recovered

for each individual:
if individual.compartment != susceptible:
continue
maybe (depending on random number & nummsgs):
individual.compartment = infected

for each individual:
individual.nummsgs = 0

这似乎可以更好地捕捉整体流程(收集和记录总计数的净值,您可以在概念上将其作为最后一个循环的一部分)。

关于language-agnostic - 将数学问题转换为离散事件模拟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2345959/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com