在java中绘制数据并使用余弦进行最小二乘回归
我有想要绘制的数据,更重要的是,使用余弦(而不是使用多项式)进行最小二乘回归:
有什么建议吗?谢谢。
I have data I would like to plot, and more importantly, do a least squares regression on using cosines (instead of using polynomials):
Any recommendations? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
以下页面可能解决了您目标的回归部分:
http: //www.teneighty.org/software/index.html?f=fft&c=e98b8
Probably the following page solves the regression part of your aim:
http://www.teneighty.org/software/index.html?f=fft&c=e98b8
您可能会发现这个演示最小二乘法和数据拟合很有帮助,因为它解决了您的一些问题。
You might find this demo Least Squares & Data Fitting helpful since it solves a few of your problems.
只是一点警告性建议。如果您认为您的基础函数以余弦级数为基础,那么使用傅立叶级数是有意义的;但是,如果您将其用作任意函数(形状未知)的基础,您可能会更好地尝试猜测更具体的基础函数类型(多项式、指数等)。
我对这样的一个系列做了一些约束优化,并且函数波动太大,很难说我的拟合是否有意义;我的拟合函数有大量的局部最大值。
Just a bit of cautionary advice. Using a Fourier series makes sense if you think your underlying function has a cosine series as a basis; however, if you are using it as a basis for an arbitrary function (with unknown shape), you may do better trying to guess at a more specific underlying function type (polynomial, exponential, etc).
I did some constrained optimization on such a series, and the function wiggled around so much it was hard to say if my fit was meaningfull; my fit function had great number of local maxima.
MathGL 可以绘图、拟合(借助 GSL)并显示拟合结果 - 请参阅 此示例
MathGL can plot, fit (by help of GSL) and show fitting result - see this sample