Tag: apache commons math

如何通过RealMatrix乘以RealVector?

如何通过RealMatrix乘以给定的RealMatrix ? 我在两个类上找不到任何“乘法”方法,只有preMultiply但似乎不起作用: // point to translate final RealVector p = MatrixUtils.createRealVector(new double[] { 3, 4, 5, 1 }); // translation matrix (6, 7, 8) final RealMatrix m = MatrixUtils.createRealMatrix(new double[][] { {1, 0, 0, 6}, {0, 1, 0, 7}, {0, 0, 1, 8}, {0, 0, 0, 1} }); // p2 = mxp final RealVector […]

根据哈希创建一个统一的随机数

我需要一个基于由字符串和长整数组成的密钥的良好伪随机数。 当我使用相同的密钥查询时,我应该得到相同的随机数,而且,如果我使用略微不同的密钥进行查询,我应该得到一个非常不同的数字,即使说密钥中的长度是1,我试过这个代码并且随机数是唯一的,但对于相似的数字,它们似乎是相关的。 import java.util.Date; import java.util.Random; import org.apache.commons.lang3.builder.HashCodeBuilder; public class HashKeyTest { long time; String str; public HashKeyTest(String str, long time) { this.time = time; this.str = str; } @Override public int hashCode() { return new HashCodeBuilder().append(time).append(str).toHashCode(); } public static void main(String[] args) throws Exception { for(int i=0; i<10; i++){ long time = new Date().getTime(); […]

使用Apache Commons Math确定置信区间

我有一组基准数据,我使用Apache Math Commons计算汇总统计数据。 现在我想使用包来计算例如运行时间测量的算术平均值的置信区间。 这有可能吗? 我确信该软件包支持这一点,但是我不知道从哪里开始。 这是我在Brent Worden建议的帮助下最终使用的解决方案: private double getConfidenceIntervalWidth(StatisticalSummary statistics, double significance) { TDistribution tDist = new TDistribution(statistics.getN() – 1); double a = tDist.inverseCumulativeProbability(1.0 – significance / 2); return a * statistics.getStandardDeviation() / Math.sqrt(statistics.getN()); }

使用概率分布生成范围内的随机整数

我有一个问题,我想使用概率分布生成1到5之间的一组随机整数值。 Poisson和Inverse Gamma是两个分布,显示了我所发现的特征(多数均值,更低的数字)。 我正在寻找使用Apache Commons Math,但我不知道如何使用可用的发行版生成我想要的数字。

Java – 使用Apache Commons Mathematic Library计算派生

我在使用apache commons数学库时遇到问题。 我只想创建像f(x)= 4x ^ 2 + 2x这样的函数,我想计算这个函数的导数 – > f’(x)= 8x + 2 我阅读了有关差异化的文章( http://commons.apache.org/proper/commons-math/userguide/analysis.html ,第4.7节)。 有一个我不明白的例子: int params = 1; int order = 3; double xRealValue = 2.5; DerivativeStructure x = new DerivativeStructure(params, order, 0, xRealValue); DerivativeStructure y = f(x); //COMPILE ERROR System.out.println(“y = ” + y.getValue(); System.out.println(“y’ = ” + y.getPartialDerivative(1); System.out.println(“y” […]

如何在java apache数学中使用SimplexSolver或SimplexOptimizer?

我正在尝试使用apache commons数学库版本3.5+来解决优化问题。 基本上,我正在尝试将(gamma)分布拟合到某些数据点。 我似乎找不到任何关于如何使用新的(版本3.5)优化工具(如SimplexSolver,SimplexOptimizer或OptimizationData)的简单示例来解决一个简单的优化问题。 之前已经提出了类似的问题,但所有答案似乎都是针对旧版本的apache数学 – 在3.5版本中进行了重组,并且我找不到任何示例代码。 有没有人有一个工作示例如何使用新的优化器或求解器? 我对SimplexOptimizer最感兴趣,但此时任何事情都会有用。