需要帮助理解 Apache Commons Math BracketFinder
我首先要说的是,这感觉应该很容易……但对我来说并不完全明显。我正在尝试使用 BrentOptimizer 来查找函数的局部最小值和最大值。我知道这些的周期性,我觉得我应该能够使用 BracketFinder 将最优值括起来,然后将其发送到 BrentOptimizer。
因此,对于一个简单的情况,请考虑:
f(x) = sin(x)
我们知道最大值位于 Pi/2 处,最小值位于 3Pi/2 处。如果我从零开始并沿着函数移动,我将如何寻找 Pi/2 处的根?它实际上取决于构造函数参数和初始点。是否有任何最佳实践(假设您对函数的形状有所了解)可以用来以合理的方式设置这些参数?
谢谢
I will start off by saying that this feels like it should be easy... but it's not entirely obvious to me. I am trying to use the BrentOptimizer to find local minima and maxima of a function. I have an idea of the periodicity of these, and I feel like I should be able to use the BracketFinder to bracket the optimums and then send that off to the BrentOptimizer.
Her is the documentation: http://commons.apache.org/math/api-2.2/org/apache/commons/math/optimization/univariate/BracketFinder.html
So for a simple case, consider:
f(x) = sin(x)
We know that there is a max at Pi/2 and a min at 3Pi/2. If I were starting at zero and moving along the function, how would I go looking for that root at Pi/2? It really comes down to the constructor arguments and the initial points. Are there any best practices (assuming you know a little bit about the shape of your function) that I can use to set these parameters in a reasonable way?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您现在可能已经解决了这个问题,但是括号方法根本不需要任何初始点,
BracketFinder
的目的是找到一个开始猜测,您应该在调用 BrentOptimizer。在BracketFinder
中应用默认构造函数应该没问题。收到包围点后,使用三点
optimize
抽象基类中定义的方法 BaseAbstractUnivariateOptimizer,其中min
,max
、startValue
取自BracketFinder
:sgetLo()
、getHi() 和
getMid()
。BracketFinder 实现显然是基于 数值食谱,本书 C 版本中的第 10.1 章。这可以为您提供有关所使用的包围原则的更多背景知识。
You have probably sorted this out by now, but the bracketing method does not expect any initial points at all, the intention with
BracketFinder
is to find a starting guess that you should apply in your call to the BrentOptimizer. It should be OK to apply the default constructor inBracketFinder
.After having received bracketing points, use the three-point
optimize
method defined in the abstract base class BaseAbstractUnivariateOptimizer, wheremin
,max
,startValue
are taken from theBracketFinder
:sgetLo()
,getHi()
andgetMid()
, respectively.The BracketFinder implementation is obviously based on the one found in Numerical Recipes, chapter 10.1 in the C version of the book. This could give you some more background on the bracketing principles used.