Minimize the difference between set of values

I have a parametric function that produce set of values. I want to optimize the function's parameters so the the output values are equal as possible regardless their values. for example:

y = f(x; a,b) ;  x,y are vectors with N values, a,b are single value paramters


I am using non-derivative optimization since the function is complicated and non-derivative. Currently I am trying with the Genetic Algorithm.

What is important for me is that max(y) - min(y) is minimum. However, when I chose the previous criteria as an objective function, the optimization became very slow (more iterations needed to reach a reasonable error). However, if I tried to minimize the standard deviation of the output values, the optimization algorithm reaches a reasonable solution much faster.

My questions:

• Why I am facing this behavior? I mean my goal is to minimize max(y) - min(y). However, when I minimize std(y), I got a better max(y) - min(y) in less iterations. Is this expected? why?
• In my case, what is the most logical objective function should I use? std(y) is good but I was wondering if there was a better one
• Did you try to compute what (x, y) values in your dataset wear min(y) and max(y)? Possibly your $f$ function shape is unfit to bring these values together. By using std(y), you make the algorithm work not only on these extreme values, but all values together. Does the std(y)criterion approach provide the same actual results for max(y) - min(y)? Commented Sep 21, 2018 at 11:21
• Thanks for your comment. Maybe there is misunderstanding, the function itself produces a set of values stored in vector called y. So, min(y) and max(y) are the result of the same x.. Or I could not understand your comment Commented Sep 21, 2018 at 11:35
• OK - Indeed, I initially misunderstood, now it is clear. Can you add some details on your dataset? Such as how many (x, y) you have in your statistics (I guess you have multiple couples). When you say that the std(y) approach provides better results for the max(y) - min(y) metric, is it on max(max-min) or else? Commented Sep 21, 2018 at 11:55
• Are you min(y) and max(y) values initially close to 0? How does it behave with, say, -1 + min(y)/max(y) (avoiding division-by-zero errors)? Commented Sep 21, 2018 at 12:59