多项式曲面拟合 numpy
如何将 2D 曲面 z=f(x,y)
与具有完整交叉项的 numpy 多项式拟合?
How do I fit a 2D surface z=f(x,y)
with a polynomial in numpy with full cross terms?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这本质上是数值病态的,但你可以这样做:
添加的项越多,数值上的情况就越糟糕。您确定要进行多项式插值吗?
还有其他多项式的基,其值矩阵的条件不是那么糟糕,但我不记得它们叫什么了;不过,任何大学水平的数值分析教科书都会有这种材料。
This is inherently numerically ill-conditioned but you could do something like this:
The more terms you add, the worse things get, numerically. Are you sure you want a polynomial interpolant?
There are other bases for polynomials for which the matrix of values is not so badly conditioned but I can't remember what they are called; any college-level numerical analysis textbook would have this material, though.
您可以结合使用
polyvander2d
和polyval2d
,但需要使用polyvander2d
的设计矩阵输出自行进行拟合,可能涉及缩放等等。应该可以从这些工具构建一个Polynomial2d
类。You can use a combination of
polyvander2d
andpolyval2d
, but will need to do the fit yourself using the design matrix output frompolyvander2d
, probably involving scaling and such. It should be possible to build a classPolynomial2d
from those tools.