def pcp(pred, target, dist_func, threshold, reduce=True):
    """
    Computes the percentage of correct predictions (PCP) between pred
    and target.

    Args:
        pred(np.ndarray): array of predicted data.
        target(np.ndarray): array of target data.
        dist_func(function): function to use to compute distance.
        threshold(float): threshold to consider the detection correct.
        reduce(bool): if reduction method should be applied.

    Returns:
        (np.ndarray): pcp between pred and target

    """
    dists = dist_func(pred, target)
    pck = dists < threshold
    return pck.mean() if reduce else pck