def calculate_ef_covar(ef_structure1, ef_structure2):
    """
    determine the active and decoy covariance of the enrichment factors, covara, and covard, respectively.
    :param efstructure_1: list [(id, best_score, best_query, status, gamma), ...,]
    :param ef_structure2: list [(id, best_score, best_query, status, gamma), ...,]
    :return (covar_a, covar_d): tuple
    """

    # split data by activity class
    actives1, decoys1 = splitter(ef_structure1)
    actives2, decoys2 = splitter(ef_structure2)

    # covariance due to actives = E[{gamma2 - E(gamma2)a} * {gamma1 - E(gamma1)a}]a
    gamma1 = [x[4] for x in actives1]
    gamma2 = [x[4] for x in actives2]
    covara = np.cov(gamma1, gamma2)[0][1]

    # covariance due to decoys = E[{gamma2 - E(gamma2)d} * {gamma1 - E(gamma1)d}]
    gamma1 = [x[4] for x in decoys1]
    gamma2 = [x[4] for x in decoys2]
    covard = np.cov(gamma1, gamma2)[0][1]

    return covara, covard