本文作者:合肥工业大学 管理学院 钱洋 email:1563178220@qq.com 。
以下内容为自己学习用,内容可能有不到之处,欢迎交流。
未经本人允许禁止转载。
背景
在编写多元正太分布函数和多元t分布函数时,常遇到要求解,协方差矩阵对应行列式的值。
math3求解行列式的值
在math3中提供了求解行列式值的方法,下面将以一个具体案例,介绍其使用。
如下为Java代码:
package test.SundataPro;
import org.apache.commons.math3.linear.Array2DRowRealMatrix;
import org.apache.commons.math3.linear.LUDecomposition;
import org.apache.commons.math3.linear.RealMatrix;
public class Test3 {
public static void main(String[] args) {
//行列式矩阵
double d [][]=new double[][]{{2,1,2},{-4,3,1},{2,3,5}};
RealMatrix mat = new Array2DRowRealMatrix(d);
//求解
LUDecomposition lu = new LUDecomposition(mat);
System.out.println(lu.getDeterminant());
}
}
程序的输出结果为:
LUDecomposition的其他用法
另外,LUDecomposition类还有其他用法,有兴趣的读者可以参考下面的网址学习:
https://www.programcreek.com/java-api-examples/index.php?api=org.apache.commons.math3.linear.LUDecomposition