Minimization problem: find the largest interval with lowest average value
Show older comments
Dear all,
I am dealing with experimental data, each trial consisting of 3 values: X and Y are the problem's variables for which I swipe values in their range, and Z is the result from lab measurements. Z takes non-negative values, the lower the better. Now, visual inspection (3D plot) of those values has shown that there are multiple local minima, but I need to find one single miminum pair of X and Y.
For our problem, I believe the following formulation makes sense: find the largest region (in <X,Y> ranges) for which the average values of Z in that region is minimized. Z, let's say, is minimized when it takes values below 1e-3. The output would be a region, let's say [X1,X2] X [Y1,Y2] whose central point Xh,Yh is the point I am searching for.
How can I solve this in Matlab? Which method shall I use to properly formulate the problem?
Many thanks
Kind regads
scorbetta
Answers (2)
Image Analyst
on 8 Mar 2019
Please attach your image or 3-D plot or surface.
You can easily slice through your data at every z value finding regions in x and y. If you don't have a complete grid of x and y you can use griddedInterpolant() to create one. Then use unique to find all the unique z values and start thresholding your image to get binary images at every z value.
uniquez = unique(Z);
for k = 1 : length(z)
binaryImage = dataXY < uniquez(k);
end
Then you can simply use regionprops(binaryImage, 'MeanIntensity') in that loop to get the mean intensity of all the blobs and look for the lowest value
props = regionprops(binaryImage, 'MeanIntensity', 'Area');
allAreas = [props.Area];
allMeanIntensities = [props.MeanIntensity]
thisMin(k) = min(allMeanIntensities)
Then, outside the loop compute the global overall min
overallMin = min(thisMin);
The problem is that the overall min will occur at exactly the point where you have the minimum Z, which is the obvious/trivial answer. It will have zero area because it occurs at just one point. That's why I measured the area. You might want to limit your min to regions that have some minimum acceptable area and ignore those that are smaller.
John D'Errico
on 8 Mar 2019
Edited: John D'Errico
on 8 Mar 2019
0 votes
Sorry. I think you are trying to solve this the wrong way, making the problem more complex than it already is.
You really want to find the global min, of a function of TWO variables. To solve that problem, you are turning it into a mimization problem with FOUR variables. (Thus the coordinates of two opposite corners of the box containing that minimum average value.) 4 variable problems are much more complex than are 2 variable problems, essentially because the search space is far more complicated, much larger. And even that 4 variable problem is one that will have multiple local minima. So you would probably need to use the global optimization toolbox just to solve it. And even if the 4 variable box does contian the global minima, there is no reason to believe the global solution really lies at the center of that box. This is a rabbit hole you don't want to dive into, even if Alice went in first. ;-)
So what if it ia a problem with multiple local minima? Use the global optimization toolbox. There are lots of tools in there that will be able to solve your 2 variable problem far more easily than you will be able to formulate and solve the 4 variable problem you are trying to turn this into.
Categories
Find more on Resampling Techniques in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!