mpcrl.util.math.nchoosek#

mpcrl.util.math.nchoosek(n, k)[source]#

Emulates MATLAB’s nchoosek, and returns the binomial coefficient, i.e., the number of combinations of n items taken k at a time. If n is an array, then it is flatten and all possible combinations of its elements are returned.

Parameters:
nint or array_like

Number of elements or array of elements to choose from.

kint

Number of elements to choose.

Returns:
int or array

Depending on the type of input n, the output is either the total number of combinations or the combinations in a matrix.

Return type:

int | ndarray