comb
- comb(N, k, exact=False, repetition=False)[source]
The number of combinations of N things taken k at a time.
This is often expressed as “N choose k”.
When exact=False, the result is approximately and efficiently computed using the following formula:
\[\exp\left\{\ln{\Gamma(N+1)} - [\ln{\Gamma(k+1)} + \ln{\Gamma(N+1-k)}]\right\}\]using the Gamma function.
- Parameters:
N (np.ndarray) – The number of things.
k (np.ndarray) – The number of elements taken.
exact (bool, optional) – If True, the result is computed exactly and returned as an integer type. Currently, vectorization is not supported for exact=True.
repetition (bool, optional) – If repetition is True, then the number of combinations with repetition is computed.
- Returns:
comb – The number of combinations of N things taken k at a time.
- Return type:
np.ndarray