import random


def pick_from_distribution(input_map):
    """
    Generates an item from a distribution map
    :param input_map: The dictionary of items to their probabilities
    :return: An item from the dictionary
    """
    rand = random.random()
    total = 0.0
    for item, prob in input_map.iteritems():
        total += prob
        if total > rand:
            return item

    # shouldn't get here if probabilities
    return random.choice(input_map.keys())