scipy.misc.comb

scipy.misc.comb(N, k, exact=0)[source]

The number of combinations of N things taken k at a time.

This is often expressed as “N choose k”.

Parameters :

N : int, ndarray

Number of things.

k : int, ndarray

Number of elements taken.

exact : int, optional

If exact is 0, then floating point precision is used, otherwise exact long integer is computed.

Returns :

val : int, ndarray

The total number of combinations.

Notes

  • Array arguments accepted only for exact=0 case.
  • If k > N, N < 0, or k < 0, then a 0 is returned.

Examples

>>> k = np.array([3, 4])
>>> n = np.array([10, 10])
>>> sc.comb(n, k, exact=False)
array([ 120.,  210.])
>>> sc.comb(10, 3, exact=True)
120L

Previous topic

scipy.misc.central_diff_weights

Next topic

scipy.misc.derivative