我正在尝试构建一个系统,我需要找到一组线性方程的解决方案,其中包含比方程更多的变量.
问题归结为以下几点:
想象一组方程式:
A = A1*X1 + A2*X2 + ... + AnXn
B = B1*X1 + B2*X2 + ... + BnXn
Run Code Online (Sandbox Code Playgroud)
如何为此系统找到一个或多个(正)整数解?
注意:我一直在查看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());
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用apache.commons.math库计算将R脚本转换为java .我可以用org.apache.commons.math.analysis.interpolation.LoessInterpolator代替R loess吗?我无法得到相同的结果.
编辑.
这里要说的是创建一个随机的阵列(X,Y)和计算与LoessInterpolator或通过调用R.在结束时黄土的Java程序,结果被打印.
import java.io.*;
import java.util.Random;
import org.apache.commons.math.analysis.interpolation.LoessInterpolator;
public class TestLoess
{
private String RScript="/usr/local/bin/Rscript";
private static class ConsummeInputStream
extends Thread
{
private InputStream in;
ConsummeInputStream(InputStream in)
{
this.in=in;
}
@Override
public void run()
{
try
{
int c;
while((c=this.in.read())!=-1)
System.err.print((char)c);
}
catch(IOException err)
{
err.printStackTrace();
}
}
}
TestLoess()
{
}
private void run() throws Exception
{
int num=100;
Random rand=new Random(0L);
double x[]=new double[num];
double y[]=new double[x.length];
for(int …Run Code Online (Sandbox Code Playgroud) 我一直在寻找使用apache common math 3.0为特定数据集生成垃圾箱(通过指定低频段,高频段和所需的频段数).我看过频率http://commons.apache.org/math/apidocs/org/apache/commons/math3/stat/Frequency.html 但它没有给我我想要的东西..我想要一个给我的方法间隔中值的频率(例如:0到5之间有多少个值).有什么建议或想法吗?
我试图通过使用apache-commons的Simplex解算器解决以下线性问题:org.apache.commons.math3.optim.linear.SimplexSolver.
n行
m数是列数
L是每行总和的全局限制
这是我到目前为止:
List<LinearConstraint> constraints = new ArrayList<>();
double[][] A = calculateAValues();
// m = count of columns
// constraint 1: the sum of values in all column must be <= 1
for(int i = 0; i < m; i++) {
double[] v = new double[n];
for(int j=0; j < n; j++) {
v[j] = 1;
}
constraints.add(new LinearConstraint(v, Relationship.LEQ, 1));
}
// n = count of rows
// constraint 2: sum of …Run Code Online (Sandbox Code Playgroud) 我正在寻找一个包,它为非对称(偏斜)正态分布以及泊松和指数分布提供数学函数.
我最初查看了Colt包,但它没有提供反向累积函数.
所以我改为Apache Commons Math3,它提供了更全面的功能集,包括所有发行版的反向累积概率.
然而,现在我再次撞墙,因为我需要将正态分布参数化为非对称形状(即平均值的左侧部分与平均值的右侧部分不同).你知道任何支持以上所有的软件包吗?
我想计算双打流的平均值.这是一个简单的任务,只需要存储double和int.我是使用apache commons SummaryStatistics类做的.但是,在测试时我注意到SummaryStatistics意味着浮点错误,我自己的python实现没有.经过进一步检查,我发现公共区域正在使用以下算法的版本:
static double incMean(double[] data) {
double mean = 0;
int number = 0;
for (double val : data) {
++number;
mean += (val - mean) / number;
}
return mean;
}
Run Code Online (Sandbox Code Playgroud)
这有时会导致小的浮点错误,例如
System.out.println(incMean(new double[] { 10, 9, 14, 11, 8, 12, 7, 13 }));
// Prints 10.500000000000002
Run Code Online (Sandbox Code Playgroud)
这也是番石榴实用程序DoubleMath.mean使用的平均算法.我觉得他们都使用上面的算法而不是更天真的算法似乎很奇怪:
static double cumMean(double[] data) {
double sum = 0;
int number = 0;
for (double val : data) {
++number;
sum += val;
}
return sum / number;
} …Run Code Online (Sandbox Code Playgroud) 我有一个问题,我想使用概率分布生成1到5之间的一组随机整数值.
Poisson和Inverse Gamma是两个分布,它们显示了我所发现的特征(多数均值,更低的数字).
我正在寻找使用Apache Commons Math,但我不知道如何使用可用的发行版生成我想要的数字.
我一直在寻找一种方法来计算给定列表中每个值的百分等级,到目前为止我还没有成功.
org.apache.commons.math3为您提供了一种从值列表中获取第p个百分位数的方法,但我想要的是相反的.我想对列表中的每个值进行排名.是否有人知道一个库或Apache公共数学方法来实现这一目标?
例如:给定一个值列表{1,2,3,4,5},我希望每个值具有百分等级,最大百分位数为99或100,最小值为0或1.
更新的代码:
public class TestPercentile {
public static void main(String args[]) {
double x[] = { 10, 11, 12, 12, 12, 12, 15, 18, 19, 20 };
calculatePercentiles(x);
}
public static void calculatePercentiles(double[] arr) {
for (int i = 0; i < arr.length; i++) {
int count = 0;
int start = i;
if (i > 0) {
while (i > 0 && arr[i] == arr[i - 1]) {
count++;
i++;
}
}
double perc …Run Code Online (Sandbox Code Playgroud) 我在我的项目中使用 apache-commons-math RealMatrix 来处理矩阵运算,但是我无法以正确的格式打印它。
到目前为止,对于我拥有的每个矩阵,它都是这样的:
double coord[][] = new double[3][3];
coord[0][0] = 1d;
coord[0][1] = 0d;
coord[0][2] = 0d;
coord[1][0] = 2d;
coord[1][1] = 1d;
coord[1][2] = 1d;
coord[2][0] = 3d;
coord[2][1] = 2d;
coord[2][2] = 0d;
System.out.println("coordinates [nó, x, y]");
for(int co = 0 ; co < 3 ; co++){
for(int or = 0 ; or < 3 ; or++){
System.out.printf("%10.5f\t",coord[co][or]);
}
System.out.print("\n");
}
Run Code Online (Sandbox Code Playgroud)
输出:
coordinates [nó, x, y]
1,00000 0,00000 0,00000
2,00000 1,00000 1,00000
3,00000 2,00000 0,00000
Run Code Online (Sandbox Code Playgroud)
但是当我使用 …