Example usage for org.apache.commons.math3.exception.util LocalizedFormats BINOMIAL_INVALID_PARAMETERS_ORDER

List of usage examples for org.apache.commons.math3.exception.util LocalizedFormats BINOMIAL_INVALID_PARAMETERS_ORDER

Introduction

In this page you can find the example usage for org.apache.commons.math3.exception.util LocalizedFormats BINOMIAL_INVALID_PARAMETERS_ORDER.

Prototype

LocalizedFormats BINOMIAL_INVALID_PARAMETERS_ORDER

To view the source code for org.apache.commons.math3.exception.util LocalizedFormats BINOMIAL_INVALID_PARAMETERS_ORDER.

Click Source Link

Usage

From source file:org.gitools.analysis.groupcomparison.format.math33Preview.CombinatoricsUtils.java

/**
 * Check binomial preconditions./*from  w w w  .  j a va 2  s  . co  m*/
 *
 * @param n Size of the set.
 * @param k Size of the subsets to be counted.
 * @throws NotPositiveException      if {@code n < 0}.
 * @throws NumberIsTooLargeException if {@code k > n}.
 */
public static void checkBinomial(final int n, final int k)
        throws NumberIsTooLargeException, NotPositiveException {
    if (n < k) {
        throw new NumberIsTooLargeException(LocalizedFormats.BINOMIAL_INVALID_PARAMETERS_ORDER, k, n, true);
    }
    if (n < 0) {
        throw new NotPositiveException(LocalizedFormats.BINOMIAL_NEGATIVE_PARAMETER, n);
    }
}