def compute_err_score(true_positives, n_ref, n_est):
    """Compute error score metrics.

    Parameters
    ----------
    true_positives : np.ndarray
        Array containing the number of true positives at each time point.
    n_ref : np.ndarray
        Array containing the number of reference frequencies at each time
        point.
    n_est : np.ndarray
        Array containing the number of estimate frequencies at each time point.

    Returns
    -------
    e_sub : float
        Substitution error
    e_miss : float
        Miss error
    e_fa : float
        False alarm error
    e_tot : float
        Total error

    """
    n_ref_sum = float(n_ref.sum())

    if n_ref_sum == 0:
        warnings.warn("Reference frequencies are all empty.")
        return 0., 0., 0., 0.

    # Substitution error
    e_sub = (np.min([n_ref, n_est], axis=0) - true_positives).sum()/n_ref_sum

    # compute the max of (n_ref - n_est) and 0
    e_miss_numerator = n_ref - n_est
    e_miss_numerator[e_miss_numerator < 0] = 0
    # Miss error
    e_miss = e_miss_numerator.sum()/n_ref_sum

    # compute the max of (n_est - n_ref) and 0
    e_fa_numerator = n_est - n_ref
    e_fa_numerator[e_fa_numerator < 0] = 0
    # False alarm error
    e_fa = e_fa_numerator.sum()/n_ref_sum

    # total error
    e_tot = (np.max([n_ref, n_est], axis=0) - true_positives).sum()/n_ref_sum

    return e_sub, e_miss, e_fa, e_tot
Compute error score metrics.

    Parameters
    ----------
    true_positives : np.ndarray
        Array containing the number of true positives at each time point.
    n_ref : np.ndarray
        Array containing the number of reference frequencies at each time
        point.
    n_est : np.ndarray
        Array containing the number of estimate frequencies at each time point.

    Returns
    -------
    e_sub : float
        Substitution error
    e_miss : float
        Miss error
    e_fa : float
        False alarm error
    e_tot : float
        Total error