perm — SciPy v1.15.2 Manual (original) (raw)

scipy.special.

scipy.special.perm(N, k, exact=False)[source]#

Permutations of N things taken k at a time, i.e., k-permutations of N.

It’s also known as “partial permutations”.

Parameters:

Nint, ndarray

Number of things.

kint, ndarray

Number of elements taken.

exactbool, optional

If True, calculate the answer exactly using long integer arithmetic (_N_and k must be scalar integers). If False, a floating point approximation is calculated (more rapidly) using poch. Default is False.

Returns:

valint, ndarray

The number of k-permutations of N.

Notes

Examples

import numpy as np from scipy.special import perm k = np.array([3, 4]) n = np.array([10, 10]) perm(n, k) array([ 720., 5040.]) perm(10, 3, exact=True) 720