scipy.special.binom#
- scipy.special.binom(x, y, out=None) = <ufunc 'binom'>#
- Binomial coefficient considered as a function of two real variables. - For real arguments, the binomial coefficient is defined as \[\binom{x}{y} = \frac{\Gamma(x + 1)}{\Gamma(y + 1)\Gamma(x - y + 1)} = \frac{1}{(x + 1)\mathrm{B}(x - y + 1, y + 1)}\]- Where \(\Gamma\) is the Gamma function ( - gamma) and \(\mathrm{B}\) is the Beta function (- beta) [1].- Parameters:
- x, y: array_like
- Real arguments to \(\binom{x}{y}\). 
- outndarray, optional
- Optional output array for the function values 
 
- Returns:
- scalar or ndarray
- Value of binomial coefficient. 
 
 - See also - comb
- The number of combinations of N things taken k at a time. 
 - Notes - The Gamma function has poles at non-positive integers and tends to either positive or negative infinity depending on the direction on the real line from which a pole is approached. When considered as a function of two real variables, \(\binom{x}{y}\) is thus undefined when x is a negative integer. - binomreturns- nanwhen- xis a negative integer. This is the case even when- xis a negative integer and- yan integer, contrary to the usual convention for defining \(\binom{n}{k}\) when it is considered as a function of two integer variables.- References - Examples - The following examples illustrate the ways in which - binomdiffers from the function- comb.- >>> from scipy.special import binom, comb - When - exact=Falseand- xand- yare both positive,- combcalls- binominternally.- >>> x, y = 3, 2 >>> (binom(x, y), comb(x, y), comb(x, y, exact=True)) (3.0, 3.0, 3) - For larger values, - combwith- exact=Trueno longer agrees with- binom.- >>> x, y = 43, 23 >>> (binom(x, y), comb(x, y), comb(x, y, exact=True)) (960566918219.9999, 960566918219.9999, 960566918220) - binomreturns- nanwhen- xis a negative integer, but is otherwise defined for negative arguments.- combreturns 0 whenever one of- xor- yis negative or- xis less than- y.- >>> x, y = -3, 2 >>> (binom(x, y), comb(x, y)) (nan, 0.0) - >>> x, y = -3.1, 2.2 >>> (binom(x, y), comb(x, y)) (18.714147876804432, 0.0) - >>> x, y = 2.2, 3.1 >>> (binom(x, y), comb(x, y)) (0.037399983365134115, 0.0)