/** {@inheritDoc} */ @Override public double logProbability(int x) { double ret; if (x < 0) { ret = Double.NEGATIVE_INFINITY; } else { ret = CombinatoricsUtils.binomialCoefficientLog(x + numberOfSuccesses - 1, numberOfSuccesses - 1) + logProbabilityOfSuccess * numberOfSuccesses + log1mProbabilityOfSuccess * x; } return ret; }
/** * Returns the natural {@code log} of the <a * href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial * Coefficient</a>, "{@code n choose k}", the number of * {@code k}-element subsets that can be selected from an * {@code n}-element set. * <p> * <Strong>Preconditions</strong>: * <ul> * <li> {@code 0 <= k <= n } (otherwise * {@code IllegalArgumentException} is thrown)</li> * </ul></p> * * @param n the size of the set * @param k the size of the subsets to be counted * @return {@code n choose k} * @throws NotPositiveException if {@code n < 0}. * @throws NumberIsTooLargeException if {@code k > n}. * @throws MathArithmeticException if the result is too large to be * represented by a long integer. * @deprecated use {@link CombinatoricsUtils#binomialCoefficientLog(int, int)} */ @Deprecated public static double binomialCoefficientLog(final int n, final int k) throws NotPositiveException, NumberIsTooLargeException, MathArithmeticException { return CombinatoricsUtils.binomialCoefficientLog(n, k); }
return binomialCoefficientLog(n, n - k);
/** {@inheritDoc} */ @Override public double logProbability(int x) { double ret; if (x < 0) { ret = Double.NEGATIVE_INFINITY; } else { ret = CombinatoricsUtils.binomialCoefficientLog(x + numberOfSuccesses - 1, numberOfSuccesses - 1) + logProbabilityOfSuccess * numberOfSuccesses + log1mProbabilityOfSuccess * x; } return ret; }
/** {@inheritDoc} */ @Override public double logProbability(int x) { double ret; if (x < 0) { ret = Double.NEGATIVE_INFINITY; } else { ret = CombinatoricsUtils.binomialCoefficientLog(x + numberOfSuccesses - 1, numberOfSuccesses - 1) + logProbabilityOfSuccess * numberOfSuccesses + log1mProbabilityOfSuccess * x; } return ret; }
/** * Returns the natural {@code log} of the <a * href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial * Coefficient</a>, "{@code n choose k}", the number of * {@code k}-element subsets that can be selected from an * {@code n}-element set. * <p> * <Strong>Preconditions</strong>: * <ul> * <li> {@code 0 <= k <= n } (otherwise * {@code IllegalArgumentException} is thrown)</li> * </ul></p> * * @param n the size of the set * @param k the size of the subsets to be counted * @return {@code n choose k} * @throws NotPositiveException if {@code n < 0}. * @throws NumberIsTooLargeException if {@code k > n}. * @throws MathArithmeticException if the result is too large to be * represented by a long integer. * @deprecated use {@link CombinatoricsUtils#binomialCoefficientLog(int, int)} */ @Deprecated public static double binomialCoefficientLog(final int n, final int k) throws NotPositiveException, NumberIsTooLargeException, MathArithmeticException { return CombinatoricsUtils.binomialCoefficientLog(n, k); }
/** * Returns the natural {@code log} of the <a * href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial * Coefficient</a>, "{@code n choose k}", the number of * {@code k}-element subsets that can be selected from an * {@code n}-element set. * <p> * <Strong>Preconditions</strong>: * <ul> * <li> {@code 0 <= k <= n } (otherwise * {@code IllegalArgumentException} is thrown)</li> * </ul></p> * * @param n the size of the set * @param k the size of the subsets to be counted * @return {@code n choose k} * @throws NotPositiveException if {@code n < 0}. * @throws NumberIsTooLargeException if {@code k > n}. * @throws MathArithmeticException if the result is too large to be * represented by a long integer. * @deprecated use {@link CombinatoricsUtils#binomialCoefficientLog(int, int)} */ @Deprecated public static double binomialCoefficientLog(final int n, final int k) throws NotPositiveException, NumberIsTooLargeException, MathArithmeticException { return CombinatoricsUtils.binomialCoefficientLog(n, k); }
return binomialCoefficientLog(n, n - k);
return binomialCoefficientLog(n, n - k);