In [1]:
#library
import math
import statistics

#Situation Parameters
ITI = 10 #Intertrial interval
IL = [1, 1, 1, 1] #Initial link
TL = [10, 10, 10, 10] #final link
A = [1,1,1,1] #Reward
Psr = [.2,.5] #Probability Initial link
PFr = [1, 0, .5, .5] #Probability final link reward
FE = .5 #Forced-exposure

#Free Parameters
l = .37 
a = 4.4
b = 1.4
B = 1.4
m = 1.8

#Cycle Time (C)
C = [0 for i in range(len(IL))]
for i in range(len(C)):
    C[i] = round((ITI + IL[i] + TL[i]) / (FE*(Psr[0]+Psr[1])),2)
    
#Trial Time (C/t)
t= [0 for i in range(len(C))]
for i in range(len(t)):
    try:
        t[i] = TL[i] / PFr[i]
    except:
        t[i] = 0       
        
#temporal information (H=C/t)
H = [0 for i in range(len(C))]
for i in range(len(C)):
    try:
        H[i] = C[i] / t[i]
    except:
        H[i] = 0  
#Value
V = [0 for i in range(len(H))]
for i in range(len(V)):
    try:
        V[i] = H[i]*(1-math.exp(-l*A[i]))
    except:
        V[i] = 0
        
#Proportions of suboptimal choice

#Ecuation 9
Vsub = max([V[1],V[0]])
Vopt = max([V[2],V[3]])
Psub_0 = Vsub / (Vopt + Vsub)

#Ecuation 10
Psub_1 = Vsub**a / (Vopt**a + Vsub**a) 

#Ecuation 11.1
Rsub = ((PFr[0]*A[0]) + (PFr[1]*A[1]))*Psr[0]
Ropt = ((PFr[2]*A[3]) + (PFr[2]*A[3]))*Psr[1]
Psub_2 = Rsub / (Ropt + Rsub)

#Ecuation 11.2
Psub_3 = Rsub**b / (Ropt**b + Rsub**b)

#Ecuation 12
Df = statistics.mean(TL+IL)
Ds = statistics.mean(IL)
w = 1 / (1+math.exp(-B*((Df/Ds)-m)))
Psub_4 = (w*Psub_1) + ((1-w)*Psub_3) 

print('Proportions suboptimal choice')
print('')
print('Ecuation 9   :',round(Psub_0,3))
print('Ecuation 10  :',round(Psub_1,3))
print('Ecuation 11.1:',round(Psub_2,3))
print('Ecuation 11.2:',round(Psub_3,3))
print('Ecuation 12  :',round(Psub_4,3))
Proportions suboptimal choice

Ecuation 9   : 0.667
Ecuation 10  : 0.955
Ecuation 11.1: 0.286
Ecuation 11.2: 0.217
Ecuation 12  : 0.951