我有一个问题,我想使用概率分布生成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) 我需要使用MLE从样本数据中估计Weibull分布的形状和比例参数.我检查了Apache commons Math的WeibullDistribution类,但它没有这样的功能.有什么建议吗?我需要在我的java应用程序中使用该类.
我在我的项目中使用 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)
但是当我使用 …
我正在寻找一个java库/实现,它支持以合理的精度计算β分布的逆累积分布函数(也就是分位数的估计).
当然我已经尝试过apache commons math,但是在版本3中,似乎仍然存在一些精度问题.下面引出这个问题的问题被广泛描述.
假设我想通过大量试验来计算β分布的可信区间.在apache commons math ...
final int trials = 161750;
final int successes = 10007;
final double alpha = 0.05d;
// the supplied precision is the default precision according to the source code
BetaDistribution betaDist = new BetaDistribution(successes + 1, trials - successes + 1, 1e-9);
System.out.println("2.5 percentile :" + betaDist.inverseCumulativeProbability(alpha / 2d));
System.out.println("mean: " + betaDist.getNumericalMean());
System.out.println("median: " + betaDist.inverseCumulativeProbability(0.5));
System.out.println("97.5 percentile :" + betaDist.inverseCumulativeProbability(1 - alpha / 2d)); …Run Code Online (Sandbox Code Playgroud) 我试图用公式A*EXP(-BX)对各个点(x,y)进行指数拟合,试图找到最适合我的点的A和B.
double[] xx = curveFitter.fit(new ParametricUnivariateFunction() {
public double value(double v, double... doubles) {
return doubles[0] * Math.exp(-1 * doubles[1] * v);
}
public double[] gradient(double v, double... doubles) {
return new double[]{v, 1};
}
}, new double[]{0, 0});
Run Code Online (Sandbox Code Playgroud)
我得到了一些数字,但它们不符合我的观点,似乎无法找到上述任何文档.
使用commons-math3-3.0
我试图用公共数学来计算多项式中的常数.它看起来像例程存在但我得到了这个错误.有谁看到这个问题?
我试图将这个问题转换为commons-math:https: //math.stackexchange.com/questions/121212/how-to-find-curve-equation-from-data
从绘制数据(Wolfram | Alpha链接),它看起来不是线性的.所以最好用多项式拟合.我假设您想要拟合数据:
XY 1 4 2 8 3 13 4 18 5 24 ..使用二次多项式y = ax2 + bx + c.
而wolfram alpha提供了很好的实用性.我希望我能得到像沃尔夫拉姆一样的答案.
http://www.wolframalpha.com/input/?i=fit+4%2C+8%2C+13%2C
例如,通过输入该数据,我得到:4.5 x-0.666667(线性)
这是代码和错误:
import org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression;
import org.apache.commons.math3.stat.regression.SimpleRegression;
final OLSMultipleLinearRegression regression2 = new OLSMultipleLinearRegression();
double[] y = {
4.0,
8,
13,
};
double[][] x2 =
{
{ 1.0, 1, 1 },
{ 1.0, 2, 4 },
{ 0.0, 3, 9 },
};
regression2.newSampleData(y, x2);
regression2.setNoIntercept(true);
regression2.newSampleData(y, x2);
double[] beta = regression2.estimateRegressionParameters();
for …Run Code Online (Sandbox Code Playgroud) 我正在寻找有关第三方库的建议,用于对BigDecimal/BigInteger中编码的数字进行统计分析.
Apache commons-math包含所有理想的功能(它是DescriptiveStatistics和SummaryStatistics)......但它使用的是双打而不是BigXXX实现.
由于对我的软件精度的监管要求,我需要使用BigXXX实现.但是我非常希望不要自己实现我需要的基本统计数据.
例如,编写我自己的中值算法很容易 - 但是拾取高精度数据类型似乎违反直觉,然后使用我自己的不成熟(因此,可能是错误的)方法来执行它们的统计.
我想提高室内定位框架的准确性,因此应用kalmanfilter.我发现apache commons数学库支持Kalmanfilter,所以我尝试使用它并遵循教程:https://commons.apache.org/proper/commons-math/userguide/filter.html 我想我已正确设置矩阵用于2D定位,而状态由位置和速度组成.我的问题在于方法estimatePosition().如何获得正确的pNoise和mNoise变量?为什么我必须指定它们.我认为这就是Q和R矩阵的用途......我会给予每一个帮助!
public class Kalman {
//A - state transition matrix
private RealMatrix A;
//B - control input matrix
private RealMatrix B;
//H - measurement matrix
private RealMatrix H;
//Q - process noise covariance matrix (error in the process)
private RealMatrix Q;
//R - measurement noise covariance matrix (error in the measurement)
private RealMatrix R;
//PO - error covariance matrix
private RealMatrix PO;
//x state
private RealVector x;
// discrete time interval (100ms) between to steps …Run Code Online (Sandbox Code Playgroud) java android indoor-positioning-system apache-commons-math kalman-filter
我正在尝试使用apache commons数学库版本3.5+来解决优化问题.基本上,我正在尝试将(gamma)分布拟合到某些数据点.我似乎无法找到如何使用新的(版本3.5)优化工具(如SimplexSolver,SimplexOptimizer或OptimizationData)来解决一个简单的优化问题的简单示例.
之前已经在这里提出了类似的问题,但所有答案似乎都是针对旧版本的apache数学 - 在3.5版本中进行了重组,并且我找不到任何示例代码.
有没有人有一个工作示例如何使用新的优化器或求解器?我对SimplexOptimizer最感兴趣,但此时任何东西都会有用.
java ×10
math ×3
statistics ×2
android ×1
arrays ×1
bigdecimal ×1
biginteger ×1
distribution ×1
matrix ×1
mle ×1
optimization ×1
percentile ×1
poisson ×1
probability ×1
random ×1
weibull ×1