简体   繁体   English

我如何集成到java中?

[英]How do I integrate in java?

I'm working on a cumulative distribution function and I need to be able to solve integrals in Java.我正在研究累积分布函数,我需要能够用 Java 求解积分。

I've already tried Math3 in Apache Commons, but I cannot figure that out either.我已经在 Apache Commons 中尝试过 Math3,但我也无法弄清楚。

The type of integral I need to solve is for an Integral from a lower bound to an upper bound, and I need it to integrate for a variable, say 'T'.我需要解决的积分类型是从下限到上限的积分,我需要它对一个变量进行积分,比如“T”。

The rest I can figure out, like using the variable in an equation.其余的我可以弄清楚,就像在方程中使用变量一样。 But when I tried the Simpson Integration from Math3 there were either 2 parameters or 4 parameters in the constructors.但是当我尝试 Math3 的 Simpson 积分时,构造函数中有 2 个参数或 4 个参数。 Using these:使用这些:

// Construct an integrator with default settings.
SimpsonIntegrator()

// Build a Simpson integrator with given accuracies and iterations counts.
SimpsonIntegrator(double relativeAccuracy, double absoluteAccuracy, 
    int minimalIterationCount, int maximalIterationCount)

// Build a Simpson integrator with given iteration counts.
SimpsonIntegrator(int minimalIterationCount, int maximalIterationCount)

I also don't know what it means by the accuracy.我也不知道准确率是什么意思。 And I'm not very good at Integrals, because I'm just using it for an equation to put on my calculator on the google play store.而且我不太擅长积分,因为我只是用它来计算等式,然后放在我的 google play 商店中的计算器上。

There is a true value I for your integral.你的积分有一个真正的价值I And there are the Simpson results S(n) for the numerical integration with 2n samples.并且有2n样本的数值积分的 Simpson 结果S(n)

The absolute accuracy bounds the error绝对精度限制了误差

abs(S(n)-I)

the relative accuracy is a bound for相对精度是一个界限

abs(S(n)-I)/abs(I).

The absolute error doubles when doubling the integrand, the relative error remains invariant under such scalings.当被积函数加倍时,绝对误差加倍,相对误差在这种标度下保持不变。 Both error types have their uses, for displaying purposes the relative error should be more important since it gives the number of valid digits.两种错误类型都有其用途,为了显示目的,相对错误应该更重要,因为它给出了有效数字的数量。 For instance, if the result is 0.01, then an absolute error of 0.01 gives a result between 0.00 and 0.03.例如,如果结果是 0.01,那么 0.01 的绝对误差会给出介于 0.00 和 0.03 之间的结果。 A relative error of 0.1 in the same case restricts the numerical result between 0.009 and 0.011.相同情况下 0.1 的相对误差将数值结果限制在 0.009 和 0.011 之间。


The other two numbers give the starting and bailout value for n (or 2n ).另外两个数字给出了n (或2n )的起始值和救助值。


Since I is not known, its value and the errors have to be estimated.由于I未知,因此必须估计其值和误差。 For that it is used that Simpson has error order 4, which means that asymptotically为此,使用 Simpson 的错误顺序为 4,这意味着渐近

S(n) = I + C·n^(-4)+O(n^(-6))

so that以便

16·S(2n)-S(n) = 15·I + O(n^(-6))

gives an improved value for I andI

16·n^4·(S(n)-S(2n)) = 15·C + O(n^(-2))

gives an estimate on the coefficient C which allows then to get a good estimate on the optimal n required to meet the error bounds.给出对系数C的估计,从而可以对满足误差界限所需的最佳n进行很好的估计。

C*nopt^(-4) <= min(absacc, relacc*abs(I))

nopt = ceil( pow(C/min(absacc, relacc*abs(I)), 0.25) )

So compute first approximations with the minimal n , then compute the optimal n (if smaller than the maximal n ) and confirm the first error estimates.所以用最小的n计算第一个近似值,然后计算最优的n (如果小于最大值n )并确认第一个误差估计。 If that fails, compute a new optimal n with the new approximations.如果失败,则使用新的近似值计算新的最优 n。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM