(Y, Y_em, V_Y, R, n)
return (S, S_a, S_b)
Analysis of Covariance.
Analysis of Covariance.
Analysis of Covariance .
def ancova(Y, Y_em, V_Y, R, n):
    """Analysis of Covariance."""
    # Compute the sum of all Y_em terms
    Y0 = np.sum(Y_em[:, :], axis=1)

    # Initialize each variable
    S, S_a, S_b = [np.zeros((n,)) for _ in range(3)]

    # Analysis of covariance
    for j in range(n):
        # Covariance matrix of jth term of Y_em and actual Y
        C = np.cov(np.stack((Y_em[:, j], Y.reshape(R,)), axis=0))

        # Total sensitivity of jth term         ( = Eq. 19 of Li et al )
        S[j] = C[0, 1] / V_Y

        # Covariance matrix of jth term with emulator Y without jth term
        C = np.cov(np.stack((Y_em[:, j], Y0 - Y_em[:, j]), axis=0))

        # Structural contribution of jth term   ( = Eq. 20 of Li et al )
        S_a[j] = C[0, 0] / V_Y
        
        # Correlative contribution of jth term  ( = Eq. 21 of Li et al )
        S_b[j] = C[0, 1] / V_Y

    return (S, S_a, S_b)
def ancova ( Y , Y_em , V_Y , R , n ) : # Compute the sum of all Y_em terms Y0 = np . sum ( Y_em [ : , : ] , axis = 1 ) # Initialize each variable S , S_a , S_b = [ np . zeros ( ( n , ) ) for _ in range ( 3 ) ] # Analysis of covariance for j in range ( n ) : # Covariance matrix of jth term of Y_em and actual Y C = np . cov ( np . stack ( ( Y_em [ : , j ] , Y . reshape ( R , ) ) , axis = 0 ) ) # Total sensitivity of jth term         ( = Eq. 19 of Li et al ) S [ j ] = C [ 0 , 1 ] / V_Y # Covariance matrix of jth term with emulator Y without jth term C = np . cov ( np . stack ( ( Y_em [ : , j ] , Y0 - Y_em [ : , j ] ) , axis = 0 ) ) # Structural contribution of jth term   ( = Eq. 20 of Li et al ) S_a [ j ] = C [ 0 , 0 ] / V_Y # Correlative contribution of jth term  ( = Eq. 21 of Li et al ) S_b [ j ] = C [ 0 , 1 ] / V_Y return ( S , S_a , S_b )