Matlab 中的问题最小化函数 (fmincon)

发布于 2024-10-07 19:00:55 字数 690 浏览 5 评论 0原文

我有一个函数可以根据鱼上波前的入射角来计算鱼的声学强度。我还有一些声学强度的现场测量。我想做的是找出哪种角度正态分布会导致模型数据与现场数据最匹配。

为此,我尝试使用 Matlab 函数 fmincon 来最小化以下函数:

function f = myfun(x)

TS_krm = KRM(normrnd(x(1),x(2),100,1), L);
f = sum((TS_insitu - TS_krm).^2);

因此,该函数的作用是计算我想要最小化的残差平方和。为此,我尝试使用 fmincon:

x = fmincon(@myfun, [65;8], [], [], [], [], [0;0], [90;20], [], options);

因此,我使用平均值为 65 度、标准差为 8 的起始方向。我还将平均角度范围设置为 0 到 90 度,标准角度范围为偏差范围为 0 到 20 度。

然而,它似乎没有正确找到最小化函数的平均值和标准偏差角度。通常它会输出大约 N(65,8) 的值,几乎就像它并没有真正尝试远离起点的许多其他值一样。

关于我可以做些什么来完成这项工作有什么想法吗?我知道我可以设置 TolX 和 TolFun 设置,但我不太确定它们的作用以及它们会产生什么效果。如果有帮助的话,我正在处理的典型值通常约为 -45 dB。

谢谢!

I have a function which calculates the acoustic strength of a fish depending on the incident angle of the wavefront on the fish. I also have some in situ measurements of acoustic strength. What I'm trying to do is figure out which normal distribution of angles results in the model data matching up most closely with the in situ data.

To do this, I'm trying to use the Matlab function fmincon to minimize the following function:

function f = myfun(x)

TS_krm = KRM(normrnd(x(1),x(2),100,1), L);
f = sum((TS_insitu - TS_krm).^2);

So what this function does is calculates the sum of squared residuals, which I want to minimize. To do this, I try using fmincon:

x = fmincon(@myfun, [65;8], [], [], [], [], [0;0], [90;20], [], options);

Thus, I'm using a starting orientation with a mean of 65 degrees and a standard deviation of 8. I'm also setting the mean angle bounds to be from 0 to 90 degrees and the standard deviation bounds to be from 0 to 20 degrees.

Yet it doesn't seem to be properly finding the mean and standard deviation angles which minimize the function. Usually it outputs something right around N(65,8), almost like it isn't really trying many other values far from the starting points.

Any ideas on what I can do to make this work? I know I can set the TolX and TolFun settings, but I'm not really sure what those do and what effect they'd have. If it helps, the typical values that I'm dealing with are usually around -45 dB.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

有深☉意 2024-10-14 19:00:55

您应该查看不同输入的 f 值的数量级。它可能会影响您需要放入 TolFun 中的值(最小化算法对 f 变化的容差)。例如,如果 TolFun = 1e-6 并且 f(45) 和 f(64) 之间的差为 1e-7,则算法可能会在 65 处停止。
另外,我认为您使用的算法假设函数是可微的(它使用导数来查找“下一步去哪里”),不确定您的函数是否属于这种情况。如果不是,您应该使用单纯形来找到最小值。

you should look at the order of magnitude of the values of f for different inputs. it might influence the values you need to put in TolFun (the tolerance of the minimization algorithm to changes in f). for example, if TolFun = 1e-6 and the difference between f(45) and f(64) is 1e-7, the algorithm might stop at 65.
also, i think the algorith that you are using assume that the functions is differentiable (it uses derivatives to find "where to go next"), not sure this is the case in your function. if it is not, you should use simplex to find the minimum.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文