/** * Compute n!, the<a href="http://mathworld.wolfram.com/Factorial.html"> * factorial</a> of {@code n} (the product of the numbers 1 to n), as a * {@code double}. * The result should be small enough to fit into a {@code double}: The * largest {@code n} for which {@code n! < Double.MAX_VALUE} is 170. * If the computed value exceeds {@code Double.MAX_VALUE}, * {@code Double.POSITIVE_INFINITY} is returned. * * @param n Argument. * @return {@code n!} * @throws NotPositiveException if {@code n < 0}. * @deprecated use {@link CombinatoricsUtils#factorialDouble(int)} */ @Deprecated public static double factorialDouble(final int n) throws NotPositiveException { return CombinatoricsUtils.factorialDouble(n); }
/** * Compute n!, the<a href="http://mathworld.wolfram.com/Factorial.html"> * factorial</a> of {@code n} (the product of the numbers 1 to n), as a * {@code double}. * The result should be small enough to fit into a {@code double}: The * largest {@code n} for which {@code n! < Double.MAX_VALUE} is 170. * If the computed value exceeds {@code Double.MAX_VALUE}, * {@code Double.POSITIVE_INFINITY} is returned. * * @param n Argument. * @return {@code n!} * @throws NotPositiveException if {@code n < 0}. * @deprecated use {@link CombinatoricsUtils#factorialDouble(int)} */ @Deprecated public static double factorialDouble(final int n) throws NotPositiveException { return CombinatoricsUtils.factorialDouble(n); }
/** * Compute n!, the<a href="http://mathworld.wolfram.com/Factorial.html"> * factorial</a> of {@code n} (the product of the numbers 1 to n), as a * {@code double}. * The result should be small enough to fit into a {@code double}: The * largest {@code n} for which {@code n! < Double.MAX_VALUE} is 170. * If the computed value exceeds {@code Double.MAX_VALUE}, * {@code Double.POSITIVE_INFINITY} is returned. * * @param n Argument. * @return {@code n!} * @throws NotPositiveException if {@code n < 0}. * @deprecated use {@link CombinatoricsUtils#factorialDouble(int)} */ @Deprecated public static double factorialDouble(final int n) throws NotPositiveException { return CombinatoricsUtils.factorialDouble(n); }
@Override public Object doWork(Object value){ if(null == value){ return null; } else if(value instanceof List){ return ((List<?>)value).stream().map(innerValue -> doWork(innerValue)).collect(Collectors.toList()); } else{ return CombinatoricsUtils.factorialDouble(((Number)value).intValue()); } } }
sb.append("\"NA\"\n"); } else if (n > 1) { double possibleConnexions = CombinatoricsUtils.factorialDouble(n) / (CombinatoricsUtils.factorialDouble(2) * (CombinatoricsUtils.factorialDouble(n - 2))); DecimalFormat df = new DecimalFormat("###.##"); sb.append("\"" + df.format(r / possibleConnexions) + "\"\n");
@Test public void test() { final int n = 15; final DoubleFunction1D[] f1 = HERMITE.getPolynomials(n); final DoubleFunction1D[] f2 = ORTHONORMAL.getPolynomials(n); final double x = 3.4; for (int i = 0; i < f1.length; i++) { assertEquals( f1[i].applyAsDouble(x) / Math.sqrt(CombinatoricsUtils.factorialDouble(i) * Math.pow(2, i) * Math.sqrt(Math.PI)), f2[i].applyAsDouble(x), EPS); } }
/** * {@inheritDoc} */ @Override public GaussianQuadratureData generate(int n) { ArgChecker.isTrue(n > 0, "n > 0"); Pair<DoubleFunction1D, DoubleFunction1D>[] polynomials = JACOBI.getPolynomialsAndFirstDerivative(n, _alpha, _beta); Pair<DoubleFunction1D, DoubleFunction1D> pair = polynomials[n]; DoubleFunction1D previous = polynomials[n - 1].getFirst(); DoubleFunction1D function = pair.getFirst(); DoubleFunction1D derivative = pair.getSecond(); double[] x = new double[n]; double[] w = new double[n]; double root = 0; for (int i = 0; i < n; i++) { 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.applyAsDouble(_alpha + n) * GAMMA_FUNCTION.applyAsDouble(_beta + n) / CombinatoricsUtils.factorialDouble(n) / GAMMA_FUNCTION.applyAsDouble(n + _c + 1) * d * Math.pow(2, _c) / (derivative.applyAsDouble(root) * previous.applyAsDouble(root)); } return new GaussianQuadratureData(x, w); }
/** * {@inheritDoc} */ @Override public GaussianQuadratureData generate(int n) { ArgChecker.isTrue(n > 0); Pair<DoubleFunction1D, DoubleFunction1D>[] polynomials = LAGUERRE.getPolynomialsAndFirstDerivative(n, _alpha); Pair<DoubleFunction1D, DoubleFunction1D> pair = polynomials[n]; DoubleFunction1D p1 = polynomials[n - 1].getFirst(); DoubleFunction1D function = pair.getFirst(); DoubleFunction1D derivative = pair.getSecond(); double[] x = new double[n]; 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.applyAsDouble(_alpha + n) / CombinatoricsUtils.factorialDouble(n) / (derivative.applyAsDouble(root) * p1.applyAsDouble(root)); } return new GaussianQuadratureData(x, w); }
return outValue.setValue(CombinatoricsUtils.factorialDouble((int) a0.getReal()));