how to optimize a function which is no smooth but has rough minimum point
5 views (last 30 days)
Show older comments
Dear fellows,
I have a function which is not smooth. But there is a global minimum roughly. The following photos show the shape of the function. The first is over the range [0,1] and the second is over the range [0.6 0.9]. I know that the optimal value is supposed to be around 0.8. How could I find the optima which is 0.8?
0 Comments
Accepted Answer
John D'Errico
on 14 May 2014
Edited: John D'Errico
on 14 May 2014
There is a branch of statistics called Response Surface Methodology, that deals with optimizing a potentially noisy surface. Usually the idea is to use some sort of approximation to smooth out the noise, then solve for the minimum of your approximation. In RSM, you might then generate further data in the area of where you have determined the optimum to be, then repeat the analysis.
If you have only a fixed amount of data, then the trick will be to intelligently smooth the data, with a tool that is easy to solve for the minimum value. So I might suggest a spline model like my SLM toolbox , which can allow you to control how well the curve is fit, perhaps by adding more knots where the fit seems inadequate, or by adjusting a smoothing parameter.
For example, consider the curve:
x = linspace(0,pi,250);
y = -sin(x) + randn(size(x))/20;
plot(x,y,'-')
Yes, you and I know the minimum happens to fall at pi/2. (Shh! It is a secret.)
slm = slmengine(x,y,'knots',10,'reg','cross','plot','on');
Now, use slmpar (included in the toolbox) to return the minimum value and the location of that min.
[funval,minloc] = slmpar(slm,'minfun')
funval =
-1.0002
minloc =
1.5348
There are various options in the tool to help you fit virtually any function.
0 Comments
More Answers (2)
Alan Weiss
on 14 May 2014
You could try smoothing your function before minimizing. Take a convolution with a smooth function with width around 1/4 or 1/2. Even simpler, take g(x) = int(f(t),x-0.5,x+0.5) or some such average.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
0 Comments
Image Analyst
on 15 May 2014
Another option is to use a Savitzky Golay filter, sgolayfilt() in the Signal Processing Toolbox. Basically it's a window that slides along and sets the center of the window equal to the value of a polynomial you fit to the data within the window. It should probably smooth that out pretty nicely. You forgot to attach your data file so I couldn't do a demo for you with your data, but it's a pretty easy one liner.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!