partitionsRank | R Documentation |
Generate the rank (lexicographically) of partitions/compositions. These functions are the complement to partitions/compositionsSample
. See the examples below.
GMP support allows for exploration of partitions/compositions of vectors with many elements.
partitionsRank(..., v, repetition = FALSE, freqs = NULL, target = NULL)
compositionsRank(..., v, repetition = FALSE, freqs = NULL,
target = NULL, weak = FALSE)
... |
vectors or matrices to be ranked. |
v |
Source vector. If |
repetition |
Logical value indicating whether partitions/compositions should be with or without repetition. The default is |
freqs |
A vector of frequencies used for producing all partitions of a multiset of |
target |
Number to be partitioned. If |
weak |
(Compositions only) Logical flag indicating whether to allow terms of the sequence to be zero. |
These algorithms rely on efficiently ranking the n^{th}
lexicographical partition.
A vector of class integer
, numeric
, or bigz
determined by the total number of partitions/compositions
v
must be supplied.
Joseph Wood
Lexicographical order ranking/unranking
partitionsSample
, compositionsSample
mySamp = partitionsSample(30, 8, TRUE, n = 5, seed = 10, namedSample = TRUE)
myRank = partitionsRank(mySamp, v = 30, repetition = TRUE)
all.equal(as.integer(rownames(mySamp)), myRank)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.