插值建议(线性、三次?)

发布于 2024-08-05 10:43:38 字数 1436 浏览 6 评论 0原文

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

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

发布评论

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

评论(3

|煩躁 2024-08-12 10:43:38

神奇的词是“根解算器”;数学根是函数为零时的值。通过添加/减去阈值,您可以使用根查找器。

如果您知道要插值的函数,您可以设置一个非常快速的根查找器。如果您没有按照您的帖子建议的线索(“未定义”),最好的方法是“布伦特法”,“割线法”和“二分法”的组合,或者“单独割线法”。维基百科有这个方法的条目。

与您的观点相反,使用更复杂的函数并不是一个好主意。主要的性能障碍是函数评估,它随着更多的点/获得导数或更复杂的插值函数而增加。

如果你接近最大/最小/拐点,牛顿-拉夫森方法是非常糟糕的,因为接近零的导数会让你远离该点,并且还有一些其他问题。在您知道自己在做什么之前不要使用它。

The magic word is "root solver"; a mathematical root is the value where the function equals zero. By adding/subtracting the threshold, you can use root finders.

If you have a clue what function you are interpolating you can set up a very fast root finder. If you don't have a clue as suggested by your post ("undefined"), the best method is "Brent's method", a combination of "secant method" and "bisection", or the "secant method" alone. Wikipedia has an entry for this method.

Contrary to your opinion it is not a good idea to use more complicated functions. The main performance hurdle are function evaluations which increase with more points/getting the derivative or more complex interpolation functions.

The Newton-Raphson method is VERY BAD if you are near a maximum/minimum/inflection point because the near zero derivative sends you far away from the point and there are some other problems with it. Do not use it until you know what you are doing.

-残月青衣踏尘吟 2024-08-12 10:43:38

您的最后一张图片仅显示三个点,仅足以定义二次多项式,而不是三次多项式。对于三次插值,您需要四个点。三次多项式可以用不同的方式拟合;这里有两个。

最直接的方法是简单地让(唯一)多项式通过所有四个点。

另一种方法是使用切线。同样,我们需要四点。让左边的两点定义一个斜率。让多项式通过第二个点(一般来说,它不会通过第一个点),并匹配该点计算的斜率。右侧第四点和第三点也是如此。

顺便说一句,任何高阶多项式都可能不是一个好主意,因为即使存在一点点输入噪声,它们也会变得非常不稳定。

如果您提供有关您的问题领域的更多详细信息,我也许可以给出更具体的答案。例如,您的数据点来自哪里,您通常可以期望什么样的曲线,以及如果需要的话您可以返回并采样更多吗?如果需要的话,我也可以提供方程和伪代码。

更新:愚蠢的我留下了一句话,提到了两种方式,却没有把它们打出来。现在把它们打出来。

Your last picture shows only three points, which only suffice to define a quadratic polynomial, not cubic. For cubic interpolation, you'll need four points. A cubic polynomial can be fitted in different ways; here are two.

The most straightforward way is to simply let the (unique) polynomial pass through all four points.

Another way is to use tangents. Again, we need four points. Let the left two points define a slope. Have the polynomial pass through the second point (in general, it doesn't pass through the first point), and match the computed slope in that point. And same on the right side for the fourth and third point.

By the way, any higher-order polynomial is probably a bad idea, because they tend to become very unstable in the presence of even a little bit of input noise.

If you give some more details about your problem domain, I might be able to give a more specific answer. For example, where do your data points come from, what kind of curve can you generally expect, and can you go back and sample more if required? I can provide equations and pseudo-code too, if needed.

Update: silly me left a sentence referring to two ways without typing them out. Typed them out now.

人│生佛魔见 2024-08-12 10:43:38

我的数学非常生疏,但您可能会发现牛顿拉夫森方法给您带来了很好的结果。一般来说,假设迭代从“足够接近”所需的根开始,它会很快收敛到准确的解决方案。

My maths is incredibly rusty, but you may find the Newton Raphson method gives you good results. In general it converges very quickly on an accurate solution, assuming the iteration begins "sufficiently near" the desired root.

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