最小二乘 C# 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/350852/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 00:09:34  来源:igfitidea点击:

Least Squares C# library

c#mathnumerical

提问by Robert Wilkinson

I am looking to perform a polynomial least squares regression and am looking for a C# library to do the calculations for me.

我正在寻找执行多项式最小二乘回归,并正在寻找一个 C# 库来为我进行计算。

I pass in the data points and the degree of polynomal (2nd order, 3rd order, etc) and it returns either the C0, C1, C2 etc. constant values or the calculated values "predictions".

我传入数据点和多项式的次数(二阶、三阶等),它返回 C0、C1、C2 等常数值或计算值“预测”。

Note: I am using Least Squares to create some forecasting reports for disk usage, database size and table size.

注意:我使用最小二乘法为磁盘使用情况、数据库大小和表大小创建一些预测报告。

回答by dmckee --- ex-moderator kitten

In the general case you want an "optimizer" or "mimimizer". See http://en.wikipedia.org/wiki/Optimization_(mathematics)#Solversfor some exmples. I see that the first link (http://en.wikipedia.org/wiki/IMSL_Numerical_Libraries) claims to have c# support.

在一般情况下,您需要“优化器”或“最小化器”。看http://en.wikipedia.org/wiki/Optimization_(mathematics)#Solvers一些例子。我看到第一个链接 ( http://en.wikipedia.org/wiki/IMSL_Numerical_Libraries) 声称拥有 c# 支持。



Edit: For the limited use that you propose (linear or quadratic polynomials), you could just go to any copy of Numerical Recipies, grab a straight ahead implementation, and translate to your language. A general minimizer is overkill.

编辑:对于您提出的有限用途(线性或二次多项式),您可以直接访问任何数值食谱副本,获取直接实现,然后翻译成您的语言。一般的最小化器是矫枉过正的。

But note, also, that polynomials may be poor predictors.

但请注意,多项式可能是较差的预测器。

回答by Adam Tegen

You may want to check out alglib. It is in C++ instead of C#, but you might be able to write a wrapper over it.

您可能想查看alglib。它使用 C++ 而不是 C#,但您可以在其上编写包装器。

回答by JP Richardson

Here is a link for C# code on to do exactly this: http://www.trentfguidry.net/post/2009/08/01/Linear-Regression-of-Polynomial-Coefficients.aspx

以下是 C# 代码的链接,用于执行此操作:http: //www.trentfguidry.net/post/2009/08/01/Linear-Regression-of-Polynomial-Coefficients.aspx

Good luck!

祝你好运!

Edit:Apparently the above link is broken. I made another solution awhile back: http://procbits.com/2011/05/02/linear-regression-in-c-sharp-least-squares/

编辑:显然上面的链接已损坏。不久前我做了另一个解决方案:http: //procbits.com/2011/05/02/linear-regression-in-c-sharp-least-squares/

回答by Vlad Bezden

You can check library form ALGLIB under GPL licence 2.0. They have source code for C#, C++,...

您可以在 GPL 许可证 2.0 下检查库表格 ALGLIB。他们有 C#、C++、...的源代码。

http://www.alglib.net/interpolation/leastsquares.php

http://www.alglib.net/interpolation/leastsquares.php