Example usage for com.google.common.math LongMath binomial

List of usage examples for com.google.common.math LongMath binomial

Introduction

In this page you can find the example usage for com.google.common.math LongMath binomial.

Prototype

public static long binomial(int n, int k) 

Source Link

Document

Returns n choose k , also known as the binomial coefficient of n and k , or Long#MAX_VALUE if the result does not fit in a long .

Usage

From source file:net.automatalib.util.automata.ads.ADSUtil.java

/**
 * Computes an upper bound for the length of a splitting word. Based on
 * <p>// w  w  w .j  ava  2s  .  co m
 * I.V. Kogan. "Estimated Length of a Minimal Simple Conditional Diagnostic Experiment". In: Automation and Remote
 * Control 34 (1973)
 *
 * @param n
 *         the size of the automaton (number of states)
 * @param i
 *         the number of states that should be distinguished by the current splitting word
 * @param m
 *         the number of states that should originally be distinguished
 *
 * @return upper bound for the length of a splitting word
 */
public static long computeMaximumSplittingWordLength(final int n, final int i, final int m) {
    if (m == 2) {
        return n;
    }

    return LongMath.binomial(n, i) - LongMath.binomial(m - 1, i - 1) - 1;
}