CombinatorialCase102: Difference between revisions
From NARS2000
Jump to navigationJump to search
(Created page with "This case produces '''Partitions of the set''' <apll>{⍳L}</apll> into exactly <apll>R</apll> parts. As such, it produces a subset of CombinatorialCase101|<apll>101</apll>...") |
No edit summary |
||
Line 84: | Line 84: | ||
⍝ Partitions of {⍳L} into R parts | ⍝ Partitions of {⍳L} into R parts | ||
⍝ Labeled balls, unlabeled boxes, ≥1 #Balls per Box | ⍝ Labeled balls, unlabeled boxes, ≥1 # Balls per Box | ||
⍝ The number to the right in parens | ⍝ The number to the right in parens | ||
⍝ represent the corresponding row from | ⍝ represent the corresponding row from |
Revision as of 20:18, 29 April 2017
This case produces Partitions of the set {⍳L} into exactly R parts. As such, it produces a subset of 101, limiting the result to just those rows with L subsets.
- L labeled balls (1), R unlabeled boxes (0), at least one ball per box (2)
- Sensitive to ⎕IO
- Counted result is an integer scalar
- Generated result is a nested vector of nested integer vectors.
The count for this function is L SN2 R where L SN2 R calculates the Stirling numbers of the 2nd kind.
For example:
If we have 4 labeled balls (❶❷❸❹) and 2 unlabeled boxes with at least one ball per box, there are 7 (↔ 4 SN2 2) ways to meet these criteria:
|
|
|
|
|
|
|
The diagram above corresponds to the nested array
⍪102 1‼4 2 1 2 3 4 1 2 4 3 1 2 3 4 1 3 4 2 1 3 2 4 1 4 2 3 1 2 3 4 ⍝ Partitions of {⍳L} into R parts ⍝ Labeled balls, unlabeled boxes, ≥1 # Balls per Box ⍝ The number to the right in parens ⍝ represent the corresponding row from ⍝ the table in case 101. ⍪102 1‼4 4 1 2 3 4 (15) ⍪102 1‼4 3 1 2 3 4 (5) 1 3 2 4 (8) 1 2 3 4 (11) 1 4 2 3 (12) 1 2 4 3 (13) 1 2 3 4 (14) ⍪102 1‼4 2 1 2 3 4 (2) 1 2 4 3 (3) 1 2 3 4 (4) 1 3 4 2 (6) 1 3 2 4 (7) 1 4 2 3 (9) 1 2 3 4 (10) ⍪102 1‼4 1 1 2 3 4 (1) ⍪102 1‼4 0
In general, this case is related to 101 through the following identities (after sorting the items):
101 1‼L R ↔ ⊃,/102 1‼¨L,¨0..R 102 1‼L R ↔ R {(⍺=≢¨⍵)/⍵} 101 1‼L R
and is related to 112 through the following identities:
102 1‼L R ↔ {(2≢/¯1,(⊂¨⍋¨⍵)⌷¨⍵)/⍵} 112 1‼L R a←⊃102 1‼L R b← 110 1‼R R 112 1‼L R ↔ ,⊂[⎕IO+2] a[;b]