import numpy as np
start = np.array([0.6,0.4])
t_p = np.array([[0.7,0.3],
[0.4,0.6]])
e_m = np.array([[0.1,0.4,0.5],
[0.6,0.3,0.1]])
one = np.zeros(2)
twosun = np.zeros(2)
tworain = np.zeros(2)
threesun = np.zeros(2)
threerain = np.zeros(2)
twoday = np.zeros(2)
threeday = np.zeros(2)
def one_day(start,e_m):
for i in range(0,2):
one[i] = start[i]*e_m[i][0]
return one
def two_sun(t_p,e_m,maxbefore):
for i in range(0,2):
twosun[i] = maxbefore[i]*t_p[i][1]*e_m[1][1]
return twosun
def two_rain(t_p,e_m,maxbefore):
for i in range(0,2):
tworain[i] = maxbefore[i]*t_p[i][0]*e_m[0][1]
return tworain
def three_sun(t_p,e_m,maxbefore):
for i in range(0,2):
threesun[i] = maxbefore[i]*t_p[i][1]*e_m[1][2]
return threesun
def three_rain(t_p,e_m,maxbefore):
for i in range(0,2):
threerain[i] = maxbefore[i]*t_p[i][0]*e_m[0][2]
return threerain
oneday = one_day(start,e_m)
r1 = oneday[0]
s1 = oneday[1]
moneday = np.max(oneday)
twosun = two_sun(t_p,e_m,oneday)
rs2 = twosun[0]
ss2 = twosun[1]
mtwosun = np.max(twosun)
if mtwosun == rs2:
twos = "1r 2s"
else:
twos = "1s 2s"
tworain = two_rain(t_p,e_m,oneday)
rr2 = tworain[0]
sr2 = tworain[1]
mtworain = np.max(tworain)
if mtworain == sr2:
twor = "1s 2r"
else:
twor = "1r 2r"
if mtworain > mtwosun:
mtwoday = mtworain
else:
mtwoday = mtwosun
twoday[0]= mtworain
twoday[1] =mtwosun
threesun = three_sun(t_p,e_m,twoday)
rs3 = threesun[0]
ss3 = threesun[1]
threerain = three_rain(t_p,e_m,twoday)
rr3 = threerain[0]
sr3 = threerain[1]
mthreesun = np.max(threesun)
mthreerain =np.max(threerain)
if mthreesun > mthreerain:
mthreeday = mthreesun
else:
mthreeday = mthreerain
if mthreesun > mthreerain:
if mthreesun == rs3:
print(twor +"3s")
else:
print(twos +"3s")
else:
if mthreerain == sr3:
print(twos + " 3r")
else:
print(twor + " 3r")
p = moneday*mtwoday*mthreeday
print(p)
1s 2r 3r
0.00013934591999999998