Takes a single iterable as an argument and returns the same output as
    the built-in function max with two output parameters, except that where
    the maximum value occurs at more than one position in the  vector, the
    index is chosen randomly from these positions as opposed to just choosing
    the first occurance.

def fair_max(x):
    """ Takes a single iterable as an argument and returns the same output as
    the built-in function max with two output parameters, except that where
    the maximum value occurs at more than one position in the  vector, the
    index is chosen randomly from these positions as opposed to just choosing
    the first occurance.
    """
    value = max(x)
    # List indexes of max value.
    i = [x.index(v) for v in x if v == value]
    # Select index randomly among occurances.
    idx = random.choice(i)

    return idx, value