We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(7)
我找到的针对当前问题的最简单的解决方案可以在以下帖子中找到:
http://trentrichardson.com/2010/04/06/计算线性回归-in-javascript/
请注意,除了线性方程之外,它还返回 R2 分数,这可能很有用。
** 编辑 **
这是实际的代码片段:
要使用它,您只需向其传递两个数组,known_y's 和known_x's,因此这就是您可能传递的内容:
The simplest solution I found for the question at hand can be found in the following post:
http://trentrichardson.com/2010/04/06/compute-linear-regressions-in-javascript/
Note that in addition to the linear equation, it also returns the R2 score, which can be useful.
** EDIT **
Here is the actual code snippet:
To use this you just need to pass it two arrays, known_y's and known_x's, so this is what you might pass:
什么样的线性回归?对于像最小二乘这样简单的东西,我只需自己编程:
http://mathworld.wolfram.com/LeastSquaresFitting.html
数学并不太难理解,尝试一个小时左右,如果太难请告诉我,我可以尝试一下。
编辑:
发现有人做到了:
http://dracoblue。净/dev/线性最小二乘-in-javascript/159/
What kind of linear regression? For something simple like least squares, I'd just program it myself:
http://mathworld.wolfram.com/LeastSquaresFitting.html
The math is not too hard to follow there, give it a shot for an hour or so and let me know if it's too hard, I can try it.
EDIT:
Found someone that did it:
http://dracoblue.net/dev/linear-least-squares-in-javascript/159/
我发现了这个很棒的 JavaScript 库。
它非常简单,而且似乎工作得很好。
我也极力推荐 Math.JS。
I found this great JavaScript library.
It's very simple, and seems to work perfectly.
I also can't recommend Math.JS enough.
具有变异度量的简单线性回归(总平方和 = 回归平方和 + 误差平方和)、估计标准误差 SEE(残差标准误差)以及确定系数 R2 和相关性 R。
Simple linear regression with measures of variation ( Total sum of squares = Regression sum of squares + Error sum of squares ), Standard error of estimate SEE (Residual standard error), and coefficients of determination R2 and correlation R.
查看
https://web.archive。 org/web/20150523035452/https://cgwb.nci.nih.gov/cgwbreg.html(javascript 回归计算器)- 纯 JavaScript,而不是对服务器的 CGI 调用。数据和处理保留在您的计算机上。完整的 R 风格结果和 R 代码来检查工作和结果的可视化。
请参阅 OLS 的嵌入式 JavaScript 实现的源代码以及与结果相关的统计信息。
该代码是我将 GSL 库函数移植到 JavaScript 的成果。
这些代码是在 GPL 下发布的,因为它基本上是 GPL 许可的 Gnu 科学库 (GSL) 代码的行移植。
编辑:Paul Lutus 还提供了一些用于回归的 GPL 代码: http://arachnoid.com/polysolve/index .html
Check out
https://web.archive.org/web/20150523035452/https://cgwb.nci.nih.gov/cgwbreg.html (javascript regression calculator) - pure JavaScript, not CGI calls to server. The data and processing remains on your computer. Complete R style results and R code to check the work and a visualization of the results.
See the source code for the embedded JavaScript implementations of OLS and statistics associated with the results.
The code is my effort to port the GSL library functions to JavaScript.
The codes is released under GPL because it's basically line for line porting of GPL licensed Gnu Scientific Library (GSL) code.
EDIT: Paul Lutus also provides some GPL code for regression at: http://arachnoid.com/polysolve/index.html
下面是一个片段,它将采用三元组 (x, y, r) 数组,其中 r 是 (x, y) 数据点的权重并返回 [a, b],使得 Y = a*X + b 近似数据。
Here is a snippet that will take an array of triplets (x, y, r) where r is the weight of the (x, y) data point and return [a, b] such that Y = a*X + b approximate the data.
有点基于尼克·马邦的回答。
那么 y' = x * 增益 + 偏移。
Somewhat based on Nic Mabon's answer.
Then y' = x * gain + offset.