Binomial: Difference between revisions
(Created page with "{{Built-in|Binomial|!}} is a dyadic scalar function which gives the binomial coefficient between the two arguments. The...") |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Built-in|Binomial|!}} is a [[dyadic]] [[scalar function]] which gives the [[wikipedia:binomial coefficient|binomial coefficient]] between the two [[argument|arguments]]. The argument order | {{Built-in|Binomial|!}} is a [[dyadic]] [[scalar function]] which gives the [[wikipedia:binomial coefficient|binomial coefficient]] <math>\tbinom nk</math> between the two [[argument|arguments]]. The argument order <syntaxhighlight lang=apl inline>k!n</syntaxhighlight> is reversed compared to most of traditional mathematical notation's alternative notations, for example <math>C(n,k)</math> and <math>_nC_k</math>, but not others, like <math>C_n^k</math>. Binomial shares the [[glyph]] <syntaxhighlight lang=apl inline>!</syntaxhighlight> with the monadic arithmetic function [[Factorial]]. | ||
== Examples == | == Examples == | ||
For non-negative integer arguments, the binomial coefficient < | For non-negative integer arguments, the binomial coefficient <syntaxhighlight lang=apl inline>k!n</syntaxhighlight> is equal to the number of ways to choose k items out of n distinct items. For example, <syntaxhighlight lang=apl inline>3!5</syntaxhighlight> is 10 because there are 10 ways to pick 3 items out of 5: 123, 124, 125, 134, 135, 145, 234, 235, 245, 345. | ||
< | <syntaxhighlight lang=apl> | ||
0 1 2 3 4 5!5 | 0 1 2 3 4 5!5 | ||
1 5 10 10 5 1 | 1 5 10 10 5 1 | ||
</ | </syntaxhighlight> | ||
< | <syntaxhighlight lang=apl inline>k!n</syntaxhighlight> also corresponds to the k-th value (zero-indexed) on the n-th row (also zero-indexed) of [[wikipedia:Pascal's triangle|Pascal's triangle]]. | ||
< | <syntaxhighlight lang=apl> | ||
⍉∘.!⍨ 0,⍳5 | ⍉∘.!⍨ 0,⍳5 | ||
1 0 0 0 0 0 | 1 0 0 0 0 0 | ||
Line 20: | Line 20: | ||
1 4 6 4 1 0 | 1 4 6 4 1 0 | ||
1 5 10 10 5 1 | 1 5 10 10 5 1 | ||
</ | </syntaxhighlight>{{Works in|[[Dyalog APL]]}} | ||
== Properties == | == Properties == | ||
The value of < | The value of <syntaxhighlight lang=apl inline>X!Y</syntaxhighlight> equals <syntaxhighlight lang=apl inline>(!Y)÷(!X)×!Y-X</syntaxhighlight>. | ||
< | <syntaxhighlight lang=apl> | ||
Alt←{(!⍵)÷(!⍺)×!⍵-⍺} | Alt←{(!⍵)÷(!⍺)×!⍵-⍺} | ||
0 1 2 3 4 5 Alt 5 | 0 1 2 3 4 5 Alt 5 | ||
1 5 10 10 5 1 | 1 5 10 10 5 1 | ||
</ | </syntaxhighlight> | ||
In multiple implementations where [[Factorial]] is extended to use the [[wikipedia:Gamma function|Gamma function]], Binomial is defined to use the above equality for non-integers. In that case, the [[wikipedia:Beta function|Beta function]] becomes closely related to the Binomial, giving the identity < | In multiple implementations where [[Factorial]] is extended to use the [[wikipedia:Gamma function|Gamma function]] <math>\Gamma(n)</math>, Binomial is defined to use the above equality for non-integers. In that case, the [[wikipedia:Beta function|Beta function]] <math>\Beta(x,y)</math> becomes closely related to the Binomial, giving the identity <math>\Beta(X,Y)</math>{{←→}}<syntaxhighlight lang=apl inline>÷Y×(X-1)!X+Y-1</syntaxhighlight>. | ||
< | <syntaxhighlight lang=apl> | ||
1 1.2 1.4 1.6 1.8 2!5 | 1 1.2 1.4 1.6 1.8 2!5 | ||
5 6.105689248 7.219424686 8.281104786 9.227916704 10 | 5 6.105689248 7.219424686 8.281104786 9.227916704 10 | ||
2!3j2 | 2!3j2 | ||
1J5 | 1J5 | ||
</ | </syntaxhighlight>{{Works in|[[Dyalog APL]]}} | ||
== External links == | == External links == | ||
Line 45: | Line 45: | ||
=== Documentation === | === Documentation === | ||
* [ | * [https://help.dyalog.com/latest/#Language/Primitive%20Functions/Binomial.htm Dyalog] | ||
* [http://microapl.com/apl_help/ch_020_020_260.htm APLX] | * [http://microapl.com/apl_help/ch_020_020_260.htm APLX] | ||
* [https://www.jsoftware.com/help/dictionary/d410.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/bang#dyadic NuVoc] | * [https://www.jsoftware.com/help/dictionary/d410.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/bang#dyadic NuVoc] | ||
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar dyadic functions]] | {{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar dyadic functions]] |
Latest revision as of 21:50, 10 September 2022
!
|
Binomial (!
) is a dyadic scalar function which gives the binomial coefficient between the two arguments. The argument order k!n
is reversed compared to most of traditional mathematical notation's alternative notations, for example and , but not others, like . Binomial shares the glyph !
with the monadic arithmetic function Factorial.
Examples
For non-negative integer arguments, the binomial coefficient k!n
is equal to the number of ways to choose k items out of n distinct items. For example, 3!5
is 10 because there are 10 ways to pick 3 items out of 5: 123, 124, 125, 134, 135, 145, 234, 235, 245, 345.
0 1 2 3 4 5!5 1 5 10 10 5 1
k!n
also corresponds to the k-th value (zero-indexed) on the n-th row (also zero-indexed) of Pascal's triangle.
⍉∘.!⍨ 0,⍳5 1 0 0 0 0 0 1 1 0 0 0 0 1 2 1 0 0 0 1 3 3 1 0 0 1 4 6 4 1 0 1 5 10 10 5 1
Properties
The value of X!Y
equals (!Y)÷(!X)×!Y-X
.
Alt←{(!⍵)÷(!⍺)×!⍵-⍺} 0 1 2 3 4 5 Alt 5 1 5 10 10 5 1
In multiple implementations where Factorial is extended to use the Gamma function , Binomial is defined to use the above equality for non-integers. In that case, the Beta function becomes closely related to the Binomial, giving the identity ÷Y×(X-1)!X+Y-1
.
1 1.2 1.4 1.6 1.8 2!5 5 6.105689248 7.219424686 8.281104786 9.227916704 10 2!3j2 1J5