我对 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 -> 元组:(数组([ 0.46323573]), 数组([ 0.25872885]), 1, 数组([ 3.63269497]))
有人可以指出中的等效函数(如果可用)
http://commons.apache.org/math/
(或者可能在其他一些 Java 数学库中......)
最佳答案
感谢乔的指点。
以下是引用代码:
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];
关于java - numpy.linalg.lstsq 在 Apache Commons Math Java 库中等效吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5010682/