def normalize(data):
    """
    Normalizes and iterable such that its elements sum to 1.

    Parameters:

    * data - (iterable) data to be normalized

    Example:

        data = [1, 2, 3]
        data = normalize(data)
        assert sum(data) == 1
    """
    total = sum(data)
    return [d / float(total) for d in data]