Repository navigation
The multinomial coefficient - #2197
Merged
Merged
Conversation
multinomial(k_1, ..., k_m) was reserved by name in #2184. It is now (k_1 + ... + k_m)! / (k_1! ... k_m!), written so when it is parsed, as Happypig375 agreed on #2182. The factorial is the gamma function off the whole numbers, so the coefficient is symmetric in its arguments everywhere, and it has no value where an argument or their sum is a negative integer, a pole of the gamma function. multinomial(2, 3, 4) is 1260, multinomial(1/2, 1/2) is 4 / pi, and multinomial(1/2, 1/3) agrees with mpmath to 1e-25. It is not built as the product of binomial coefficients the multinomial theorem factors it into. binomial is 0 at a negative whole lower index, and that product depends on the order of the arguments there: multinomial(-3, 1) would be -2 and multinomial(1, -3) would be 0. Part of #2182. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2197 +/- ##
==========================================
- Coverage 86.56% 86.54% -0.02%
==========================================
Files 298 298
Lines 66489 66493 +4
Branches 19292 19292
==========================================
- Hits 57553 57547 -6
- Misses 4862 4872 +10
Partials 4074 4074
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
multinomial(k_1, ..., k_m)was reserved in #2184. It is now(k_1 + ... + k_m)! / (k_1! ... k_m!), written that way at parse time, as agreed on #2182. Part of #2182.Off the whole numbers the factorial is the gamma function. So the coefficient is symmetric in its arguments everywhere, and has no value where an argument or their sum is a negative integer.
It is not the product of binomials the multinomial theorem factors it into. That product depends on the argument order where
binomialis 0, at a negative whole lower index:multinomial(-3, 1)would be-2andmultinomial(1, -3)would be0."multinomial(2, 3, 4)".ToEntity().Simplify()UnhandledParseException1260"multinomial(1/2, 1/2)".ToEntity().Simplify()UnhandledParseException4 / pi"multinomial(n)".ToEntity()multinomial * nn! / n!multinomial(1/2, 1/3)agrees with mpmath to 1e-25.🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura