I need to compute combinatorials (nCr) in Python but cannot find the function to do that in math, numpy or stat libraries. Something
math
numpy
stat
Starting Python 3.8, the standard library now includes the math.comb function to compute the binomial coefficient:
Python 3.8
math.comb(n, k)
which is the number of ways to choose k items from n items without repetition n! / (k! (n - k)!):
n! / (k! (n - k)!)
import math math.comb(10, 5) # 252