Incorrect generalization for binomial/nCr
See original GitHub issuenCr is only undefined if n<0, n is an integer, AND k is not an integer.
nCr is perfectly defined for negative n and integer k.
line 74 should be
if n == nx and k != floor(k):
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Binomial coefficient - Wikipedia
In mathematics, the binomial coefficients are the positive integers that occur as coefficients in the binomial theorem. Commonly, a binomial coefficient is ...
Read more >A binomial question that requires the use of the nCr formula ...
Given that (1+ax)^n = 1 - 12x + 63x^2 + ... find the values of a and n.Challenging question involving the use of...
Read more >5.3. Generalized Permutations and Combinations
We may solve this problem in the following way, as illustrated with ... They can be generalized by the following formula, called the...
Read more >Binomial coefficients $1/2\choose k - Math Stack Exchange
I understand and am able to do it when there are no fractions and they are all positive. We learned the generalized formula...
Read more >Combinatorics Problem | Free Math Help Forum
Prove the cancellation identity for generalized binomial coefficients: if α is a real number, ... Just use the definition nCr = n!/[r!(
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
To an extent I agree, when binomial coefficients
\binom{n}{k}
, are considered as functions of two integer variables, then they are usually defined for negative integersn
. But strictly speaking, when\binom{x}{y}
is treated as a function of two real variables, I don’t think it’s unreasonable to say it is undefined forx
a negative integer andy
an integer.For the case of two real variables,
\binom{x}{y}
is typically defined bywhere Γ is the Gamma function and Β is the Beta function.
The value of the limit as
(x, y)
tends to(-n, k)
for-n
a negative integer andk
an integer depends on the direction in which(x, y)
approaches(-n, k)
. Since the binomial coefficient is not continuous at these points, I think the authors of the function made a reasonable choice to treat it as undefined there. Also, at this time, there’s likely to be downstream code that depends upon this choice, so it may break some user code to change things now.Your issue does raise a very nice point thought. This function was originally implemented as an internal function for orthogonal polynomial evaluation and only later exposed in the public API. It doesn’t have a proper docstring at this time and I think it could really use one that explains the choices made.
Sure!