import random


def roulette(probabilities):
    """Performs roulette wheel selection given the probabilities.
    
    Given a list of probabilities, selects one of the items randomly.  The
    probabilities will be scaled if necessary, so the values do not need to
    sum to 1.0.  Returns the index of the selected item.
    
    Examples
    --------
        # Randomly selected between two items, preferring the first
        roulette([0.75, 0.25])
    
    Parameters
    ----------
    probabilities : list of float
        List of probabilities of selecting each item.
    """
    rand = random.uniform(0.0, sum(probabilities))
    value = 0.0
    
    for i in range(len(probabilities)):
        value += probabilities[i]
            
        if value > rand:
            return i
        
    return 0