Combinatorial numbering rank and unrank

Translate between standard numbering and combinatorial numbering of n choose k.
103 descargas
Actualizado 13 nov 2015

Ver licencia

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)

Citar como

Brian Butler (2024). Combinatorial numbering rank and unrank (https://www.mathworks.com/matlabcentral/fileexchange/53976-combinatorial-numbering-rank-and-unrank), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2015b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Categorías
Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y MATLAB Answers.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión
1.0.0.0

* added fig.
* typo
* better fig.

* typo fixed. added 'requirement'