[issue35431] Add a function for computing binomial coefficients to the math module

2019-06-01 Thread David Radcliffe


David Radcliffe  added the comment:

I think that binomial(n, k) should return 0 when k > n or k < 0. This is a 
practical consideration. I'm concerned about evaluating sums involving binomial 
coefficients. Mathematicians are often rather loose about specifying the upper 
and lower bounds of summation, because the unwanted terms are zero anyway. 
These formulas should not result in value errors when they are implemented 
directly.

To give a simplistic example, the sum of the first n positive integers is 
binomial(n+1, 2), and the formula should still work if n is zero.

------
nosy: +David Radcliffe

___
Python tracker 
<https://bugs.python.org/issue35431>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35431] Add a function for computing binomial coefficients to the math module

2019-06-02 Thread David Radcliffe


David Radcliffe  added the comment:

I understand that pure mathematics is not the primary use case. But I would
expect that math.comb() would be used to implement mathematical formulas.
As a simple example, the number of edges in a complete graph on n vertices
is binomial(n, 2), and this should be valid if n < 2. Polynomial
interpolation is another problem where this can occur. However, I do agree
that binomial coefficients with negative arguments are relatively
unimportant.

On Sun, Jun 2, 2019 at 8:59 PM Raymond Hettinger 
wrote:

>
> Raymond Hettinger  added the comment:
>
> Here are a few other data points.  There is no consensus but either
> returning 0 or erroring out seem reasonable.
>
> MS Excel's COMBIN: If number < 0, number_chosen < 0, or number <
> number_chosen, COMBIN returns the #NUM! error value.
>
> Scipy.misc.comb: If k > N, N < 0, or k < 0, then a 0 is returned.
>
> Matlib.nchoose: Error: K must an integer between 0 and N.
>
> Maple.numbcomb: Unclear from the docs what this does
>
> Wolfram alpha:  Returns 0
> https://www.wolframalpha.com/input/?i=10+choose+12
>
> --
>
> ___
> Python tracker 
> <https://bugs.python.org/issue35431>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue35431>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com