CombinatorialCase011: Difference between revisions
From NARS2000
Jump to navigationJump to search
(Created page with "This case produces <apll>L</apll> multicombinations of <apll>R</apll> items. A multicombination is a collection of Multisets (sets which may contain repeated elements) ac...") |
No edit summary |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
This case produces <apll> | This case produces '''<apll>M</apll> Multicombinations of <apll>N</apll> items'''. A multicombination is a collection of [[Multisets]] (sets which may contain repeated elements) according to certain criteria. In particular, it produces a matrix whose rows are multisets of length <apll>M</apll>, from the values <apll>⍳N</apll>. | ||
* <apll> | * <apll>M</apll> unlabeled balls (0), <apll>N</apll> labeled boxes (1), any # balls per box (1) | ||
* Sensitive to <apll>⎕IO</apll> | * Sensitive to <apll>⎕IO</apll> | ||
* Allows Lexicographic and Gray Code order | |||
* Counted result is an integer scalar | * Counted result is an integer scalar | ||
* Generated result is an integer matrix. | * Generated result is an integer matrix. | ||
The count for this function is <apll> | The count for this function is <apll>M!M+N-1</apll>. | ||
For example: | For example: | ||
Line 78: | Line 79: | ||
<pre> | <pre> | ||
11 1‼2 3 ⍝ Multicombinations in unspecified order | |||
1 1 | |||
2 2 | |||
1 2 | |||
3 3 | |||
2 3 | |||
1 3 | |||
11 2‼2 3 ⍝ Multicombinations in Lexicographic order | |||
1 1 | 1 1 | ||
1 2 | 1 2 | ||
Line 85: | Line 93: | ||
2 3 | 2 3 | ||
3 3 | 3 3 | ||
⍝ | 11 3‼2 3 ⍝ Multicombinations in Gray Code order | ||
⍝ Unlabeled balls, labeled boxes, any # | 1 1 | ||
2 2 | |||
1 2 | |||
3 3 | |||
2 3 | |||
1 3 | |||
⍝ M Multicombinations of N items | |||
⍝ Unlabeled balls, labeled boxes, any # Balls per Box | |||
11 2‼3 3 | |||
1 1 1 | 1 1 1 | ||
1 1 2 | 1 1 2 | ||
Line 98: | Line 113: | ||
2 3 3 | 2 3 3 | ||
3 3 3 | 3 3 3 | ||
11 2‼3 2 | |||
1 1 1 | 1 1 1 | ||
1 1 2 | 1 1 2 | ||
1 2 2 | 1 2 2 | ||
2 2 2 | 2 2 2 | ||
11 2‼3 1 | |||
1 1 1 | 1 1 1 | ||
</pre> | </pre> | ||
Line 110: | Line 125: | ||
<pre> | <pre> | ||
010 | 010 1‼M N ↔ (011 1‼M,N-M-1)+[⎕IO+1] 0..M-1 | ||
011 | 011 1‼M N ↔ (010 1‼M,M+N-1)-[⎕IO+1] 0..M-1 | ||
</pre> | </pre> |
Latest revision as of 16:49, 21 October 2017
This case produces M Multicombinations of N items. A multicombination is a collection of Multisets (sets which may contain repeated elements) according to certain criteria. In particular, it produces a matrix whose rows are multisets of length M, from the values ⍳N.
- M unlabeled balls (0), N labeled boxes (1), any # balls per box (1)
- Sensitive to ⎕IO
- Allows Lexicographic and Gray Code order
- Counted result is an integer scalar
- Generated result is an integer matrix.
The count for this function is M!M+N-1.
For example:
If we have 2 unlabeled balls (●●) and 3 labeled boxes (123) with any # of balls per box, there are 6 (↔ 2!2+3-1) ways to meet these criteria:
|
|
|
|
|
|
The diagram above corresponds to:
11 1‼2 3 ⍝ Multicombinations in unspecified order 1 1 2 2 1 2 3 3 2 3 1 3 11 2‼2 3 ⍝ Multicombinations in Lexicographic order 1 1 1 2 1 3 2 2 2 3 3 3 11 3‼2 3 ⍝ Multicombinations in Gray Code order 1 1 2 2 1 2 3 3 2 3 1 3 ⍝ M Multicombinations of N items ⍝ Unlabeled balls, labeled boxes, any # Balls per Box 11 2‼3 3 1 1 1 1 1 2 1 1 3 1 2 2 1 2 3 1 3 3 2 2 2 2 2 3 2 3 3 3 3 3 11 2‼3 2 1 1 1 1 1 2 1 2 2 2 2 2 11 2‼3 1 1 1 1
In general, this case is related to that of Combinations (010) via the following identities:
010 1‼M N ↔ (011 1‼M,N-M-1)+[⎕IO+1] 0..M-1 011 1‼M N ↔ (010 1‼M,M+N-1)-[⎕IO+1] 0..M-1