def weighted_average(xvals, yvals):
    """
    Determines the weighted average of a group of masses and abundances

    :param list xvals: x values
    :param list yvals: y values
    :return: weighted average, summed intensity
    :rtype: tuple of float
    """
    if sum(yvals) == 0:  # catch for no intensity
        return sum(xvals) / len(xvals), 0.
    return (
        sum([x * y for x, y in zip(xvals, yvals)]) / sum(yvals),  # weighted m/z
        sum(yvals)  # summed intensity
    )