import math


def _efficiency(matched, population):
    """
    Helper function to generate efficiency and statistical error for each bins.

    :param matched: Number of matched classification in each bins.
    :param population: Population in each bins.
    :return: Efficiency, Error
    """

    efficiency = [
        x / y if y != 0 else 0.0 for x, y in zip(
            matched, population
        )
    ]
    error = [
        math.sqrt(eff * (1.0 - eff) / y) if y != 0 else 0.0 for eff, y in zip(
            efficiency, population
        )
    ]

    return efficiency, error