gpt4 book ai didi

java - numpy.linalg.lstsq 在 Apache Commons Math Java 库中等效吗?

转载 作者:行者123 更新时间:2023-11-30 05:06:13 25 4
gpt4 key购买 nike

我对 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com