Open bojake opened 3 years ago
Here is sample code for computing the stringency in python:
import numpy as np
def stringency(ip) :
w = 0.31047
z = np.zeros((2,9))
tg = np.array([1,1,0,0,1,1,1,0,1])
zfactor = np.where(ip==0,0,1)
z[1,:] = tg*w
z[0,:] = [0.22984333,0.22984333,0.344765,0.1723825,0.344765,0.22984333,0.344765,0.25,0.344765]
s = (ip * z[0,:] + z[1,:]) * 100.0 * zfactor
print(s)
print(s.mean())
def vstringency(ip) :
w = 0.31047
z = np.zeros((2,9))
tg = np.array([1,1,0,0,1,1,1,0,1])
zfactor = np.where(ip==0,0,1)*100.0
z[1,:] = tg*w
z[0,:] = [0.22984333,0.22984333,0.344765,0.1723825,0.344765,0.22984333,0.344765,0.25,0.344765]
stringency = np.multiply(np.add(np.multiply(ip, z[0,:]),z[1,:]),zfactor).mean(axis=1)
ip = np.append(ip, stringency.reshape(stringency.shape[0],1), axis=1)
print(ip)
stringency(np.array([0,1,2,2,1,2,2,2,2]))
vstringency(np.array([[0,1,2,2,1,2,2,2,2],[0,1,2,2,1,2,2,2,2],[0,1,2,2,1,2,2,2,2],[0,1,2,2,1,2,2,2,2]]))
Regarding this PDF:
https://www.bsg.ox.ac.uk/sites/default/files/Calculation%20and%20presentation%20of%20the%20Stringency%20Index.pdf
Page 1: The "Targeted/General" column is confusing. Are the "yes" values referring to "Yes, targeted" or is it "Yes, General?" The value 0.29 as an estimate is 7% off from the actual computed value which is 0.310417 (the value used in the table on page 2)
Page 1-2: The last sentence "Since C8 has no notion ...." followed by a formula for I[9]. The I[9] formula actually includes the 'w' factor (per the table on page 2) therefore the equation should be subscripted for I[8] which is intervention C8.