def normalize_minmax(x, x_min, x_max, min_r, max_r):
    """ Normalizing and scaling given data
    in an array x to the range of min_r 
    to max_r. x_max and x_min are maximum
    and minium of the total data x and do
    not need to be in x itself. 
    """
    x_s = ((i - x_min)/(x_max - x_min) for i in x)
    return [i * (max_r - min_r) + min_r for i in x_s]