Binomial Coefficient

Binomial coefficients are a common operation used in many applications ranging from pricing options and calculating probabilities in binomial tree models to multinomial distributions and naive Bayes classifiers. The following definition represents the binomial coefficient, which is the number of ways to choose k objects from a set of n distinct objects.

(nk)\binom{n}{k}

To implement the binomial function, see the method signature below. Note, n and k are unsigned integers, thus non-negative numbers are required.

function binomial(int64 n, int64 k) external returns (uint);

Under the hood, the following functions are utilized directly in the Neural client.

// Note n,k max int64
func (con *NeuralMath) Binomial(gas *big.Int, n, k int64) (*big.Int, error, *big.Int) {
	var bin big.Int
	return bin.Binomial(n.Int64(), k.Int64()), nil, nil
}

Last updated