def calc_average_precision(precisions, recalls):
    """Calculate average precision defined in VOC contest."""
    total_precision = 0.
    for i in range(11):
        index = next(conf[0] for conf in enumerate(recalls) if conf[1] >= i/10)
        total_precision += max(precisions[index:])
    return total_precision / 11