【问题标题】:numpy.linalg.lstsq equivalent in Apache Commons Math Java library?Apache Commons Math Java 库中的 numpy.linalg.lstsq 等效项?
【发布时间】:2011-06-27 23:54:46
【问题描述】:

我对 numpy.linalg.lstsq 有以下调用:

http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.lstsq.html

x = [[ 0.69314718] [1.09861229] [1.38629436] [1.60943791] [1.79175947] [1.94591015]]

y = [ 0.0.20273255 0.5815754 0.7520387 0.96885669 1.09861229]

l = numpy.linalg.lstsq(x, y)

返回

l -> 元组:(array([ 0.46323573]), array([ 0.25872885]), 1, array([ 3.63269497]))

有人可以指出

中的等效功能(如果有的话)

http://commons.apache.org/math/

(或者可能在其他一些 Java 数学库中......)

【问题讨论】:

标签: java python math scipy apache-commons


【解决方案1】:

感谢乔的指点。

下面是代码供参考:

double[][] testSquare = {{0.69314718}, {1.09861229}, {1.38629436}, {1.60943791}, {1.79175947}, {1.94591015}};
RealMatrix matrix = MatrixUtils.createRealMatrix(testSquare);
SingularValueDecomposition svd = new SingularValueDecomposition(matrix);
DecompositionSolver ds=svd.getSolver();
double[] b = {0.0, 0.20273255, 0.5815754, 0.7520387, 0.96885669, 1.09861229};
ds.solve(b)[0];

【讨论】:

  • 这个已经过时了等等,SingularValueDecompositionImpl已经不存在了。
猜你喜欢
  • 2016-02-28
  • 2020-08-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-24
  • 2021-12-12
  • 2014-08-06
  • 1970-01-01
相关资源
最近更新 更多