本文整理汇总了Java中org.apache.commons.math.util.MathUtils.factorialDouble方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.factorialDouble方法的具体用法?Java MathUtils.factorialDouble怎么用?Java MathUtils.factorialDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math.util.MathUtils
的用法示例。
在下文中一共展示了MathUtils.factorialDouble方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public GaussianQuadratureData generate(final int n) {
Validate.isTrue(n > 0, "n > 0");
final Pair<DoubleFunction1D, DoubleFunction1D>[] polynomials = JACOBI.getPolynomialsAndFirstDerivative(n, _alpha, _beta);
final Pair<DoubleFunction1D, DoubleFunction1D> pair = polynomials[n];
final DoubleFunction1D previous = polynomials[n - 1].getFirst();
final DoubleFunction1D function = pair.getFirst();
final DoubleFunction1D derivative = pair.getSecond();
final double[] x = new double[n];
final double[] w = new double[n];
double root = 0;
for (int i = 0; i < n; i++) {
final double d = 2 * n + _c;
root = getInitialRootGuess(root, i, n, x);
root = ROOT_FINDER.getRoot(function, derivative, root);
x[i] = root;
w[i] = GAMMA_FUNCTION.evaluate(_alpha + n) * GAMMA_FUNCTION.evaluate(_beta + n) / MathUtils.factorialDouble(n) / GAMMA_FUNCTION.evaluate(n + _c + 1) * d * Math.pow(2, _c)
/ (derivative.evaluate(root) * previous.evaluate(root));
}
return new GaussianQuadratureData(x, w);
}
示例2: generate
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public GaussianQuadratureData generate(final int n) {
Validate.isTrue(n > 0);
final Pair<DoubleFunction1D, DoubleFunction1D>[] polynomials = LAGUERRE.getPolynomialsAndFirstDerivative(n, _alpha);
final Pair<DoubleFunction1D, DoubleFunction1D> pair = polynomials[n];
final DoubleFunction1D p1 = polynomials[n - 1].getFirst();
final DoubleFunction1D function = pair.getFirst();
final DoubleFunction1D derivative = pair.getSecond();
final double[] x = new double[n];
final double[] w = new double[n];
double root = 0;
for (int i = 0; i < n; i++) {
root = ROOT_FINDER.getRoot(function, derivative, getInitialRootGuess(root, i, n, x));
x[i] = root;
w[i] = -GAMMA_FUNCTION.evaluate(_alpha + n) / MathUtils.factorialDouble(n) / (derivative.evaluate(root) * p1.evaluate(root));
}
return new GaussianQuadratureData(x, w);
}
示例3: probability
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* The probability mass function P(X = x) for a Poisson distribution.
*
* @param x the value at which the probability density function is evaluated.
* @return the value of the probability mass function at x
*/
public double probability(int x) {
if (x < 0 || x == Integer.MAX_VALUE) {
return 0;
}
return Math.pow(getMean(), x) /
MathUtils.factorialDouble(x) * Math.exp(-mean);
}
示例4: FACTDOUBLE
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
public double FACTDOUBLE(int number) {
return MathUtils.factorialDouble(number);
}