question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect generalization for binomial/nCr

See original GitHub issue

https://github.com/scipy/scipy/blob/701ffcc8a6f04509d115aac5e5681c538b5265a2/scipy/special/orthogonal_eval.pxd#L72-L76

nCr is only undefined if n<0, n is an integer, AND k is not an integer. image nCr is perfectly defined for negative n and integer k. line 74 should be

if n == nx and k != floor(k):

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
steppicommented, Dec 17, 2021

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 integers n. 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 for x a negative integer and y an integer.

For the case of two real variables, \binom{x}{y} is typically defined by 53DCA96D-ADAC-4979-957D-9082913058CA

where Γ 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 and k 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.

0reactions
HexCodeFFFcommented, Dec 19, 2021

Sure!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found