Function multinomial #
Computes the number of ways of dividing a1 + a2 + … + an distinct items into n groups of sizes a1, a2, …, an, where the order of the items within each group does not matter. These numbers are known as the multinomial coefficients, (a1 + a2 + … + an)! / (a1! a2! … an!).
The multinomial function takes either the list of a1 through an directly as an arbitrary number of arguments, or a single one-dimensional array or Matrix. It throws an error if any entry is negative or not an integer. Any zero entry corresponds to a group with no items, so it does not change the result.
The multinomial coefficient equals the product of the binomial coefficients combinations(a1 + … + ai, ai) for i = 1, …, n, which is how it is computed here. The entries can be of any numeric type that combinations() handles, written as Numeric below, and the result has the type that combinations() returns for them.
Syntax #
math.multinomial(a1, a2, ..., an) // ai are nonnegative integers
math.multinomial(a) // a is a one-dimensional array or matrix
Parameters #
| Parameter | Type | Description |
|---|---|---|
a |
Numeric[] | Matrix | …Numeric | Nonnegative integer sizes of the groups |
Returns #
| Type | Description |
|---|---|
| Numeric | Multinomial coefficient |
Throws #
Type | Description —- | ———–
Examples #
math.multinomial(3, 5, 3) // returns 9240
math.multinomial([1, 2, 1]) // returns 12
math.multinomial([2, 0, 1]) // returns 3
See also #
History #
| Version | Comment |
|---|---|
| v15.3 | Allow arguments as list of numbers; allow zero inputs; disallow input of more than one dimension |
| v1.7 | Created |