univranks: Generate the universe of rankings

View source: R/univranks.R

univranksR Documentation

Generate the universe of rankings

Description

Generate the universe of rankings given the input partition

Usage

univranks(X, k = NULL, ordering = TRUE)

Arguments

X

A ranking, an ordering, a matrix of rankings, a matrix of orderings or a number

k

Optional: the number of the non-empty subsets. It has to be used only if X is anumber. The default value is NULL, In this case the universe of rankings with n=X items are computed

ordering

The universe of rankings must be returned as orderings (default) or rankings?

Details

The function should be used with small numbers because it can generate a large number of permutations. The use of X greater than 9, of X matrices with more than 9 columns as input is not reccomended.

Value

a "list" containing the following components:

Runiv The universe of rankings
Cuniv A list containing:
R The universe of rankings in terms of rankings;
Parts for each ranking in input the produced rankings
Univinbuckets the universe of rankings within each bucket

Author(s)

Antonio D'Ambrosio antdambr@unina.it

See Also

stirling2 Stirling number of second kind.

rank2order Convert rankings into orderings.

order2rank Convert orderings into ranks.

partitions Generate partitions of n items constrained into k non empty subsets.

Examples

S2<-stirling2(4,4)$SM[4,] #indicates in how many ways 4 objects
                         #can be placed, respectively, into 1, 2,
                         #3 or 4 non-empty subsets.
CardConstr<-factorial(c(1,2,3,4))*S2  #the cardinality of rankings 
                                     #constrained into 1, 2, 3 and 4
                                     #buckets
Card<-sum(CardConstr)  #Cardinality of the universe of rankings with 4
                      #objects                                                              
U<-univranks(4)$Runiv #the universe of rankings with four objects
                     # we know that the universe counts 75 
                     #different rankings
Uk<-univranks(4,2)$Runiv    #the universe of rankings of four objects 
                           #constrained into k=2 buckets, we know they are 14
Up<-univranks(c(1,4,3,1))$Runiv  #the universe of rankings with 4 objects
                                #for which the first and the fourth item
                                #are tied


ConsRank documentation built on May 29, 2024, 7:55 a.m.