def normalize_minmax(ar):
    """
    Return the array ar scaled so that the min value is 0 and the max
    value is 1.
    """
    x = ar - min(ar)
    mmax = max(x)
    if mmax == 0:
        return x
    return x/mmax