为了解决这个问题,我们使用以下代码:
R_H, R_L, g_H, g_L, x, R_0 = Reals('R_H R_L g_H g_L x R_0')
R_HH = R_H*g_H
R_HL = R_L*g_H
R_LH = R_H*g_L
R_LL = R_L*g_L
eq1 = R_HH*x+R_HL*(1-x)
eq2 = R_LH*x+R_LL*(1-x)
equations = [
eq1 == R_0*x, eq2 == R_0*(1-x)
]
print "epidemiological equations:"
print equations
problem = [
g_H == 0.31, g_L == 0.69,
R_H == 3.93,
R_L == 0.18, x >0 , R_0 >0]
print "Problem:"
print problem
print "Solution:"
set_option(rational_to_decimal=True)
solve(equations + problem)
输出是
epidemiological equations:
[R_H·g_H·x + R_L·g_H·(1 - x) = R_0·x, R_H·g_L·x + R_L·g_L·(1 - x) = R_0·(1 - x)]
Problem:
[g_H = 31/100, g_L = 69/100, R_H = 393/100, R_L = 9/50, x > 0, R_0 > 0]
Solution:
[x = 0.31,
R_0 = 1.3425,
R_L = 0.18,
R_H = 3.93,
g_L = 0.69,
g_H = 0.31]
在此处在线运行此示例
请让我知道你的想法。非常感谢。