Combinatorial numbering rank and unrank
The sequence of combinations defined by N-choose-k (no ordering, no replacement) form a sequence that can be lengthy. These routines provide a way to translate between this sequence and the standard sequence of whole numbers and to advance within the sequence. I find this quite useful when one desires to break this sequence into equal chunks for parallel processing purposes. These sets are assumed to be sorted into lexicographic (like alphabetic) order.
Short example with n=5, k=3:
set,s rank,r
------ -------
[1 2 3] 0
[1 2 4] 1
[1 2 5] 2
[1 3 4] 3
[1 3 5] 4
[1 4 5] 5
[2 3 4] 6
[2 3 5] 7
[2 4 5] 8
[3 4 5] 9
r = kSubsetLexRank(s,k,n)
s = kSubsetLexUnrank(r,k,n)
s = kSubsetLexSuccessor(curset,k,n)
Cite As
Brian Butler (2024). Combinatorial numbering rank and unrank (https://www.mathworks.com/matlabcentral/fileexchange/53976-combinatorial-numbering-rank-and-unrank), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- AI, Data Science, and Statistics > Deep Learning Toolbox > Sequence and Numeric Feature Data Workflows >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 | * added fig.
* typo fixed. added 'requirement' |