mixle.stats.rankings.representations module

Unambiguous value types for the two common permutation representations.

class ItemOrdering(values)[source]

Bases: Sequence[int]

A permutation whose entry at each rank is the item occupying that rank.

Parameters:

values (tuple[int, ...])

to_rank_vector()[source]

Return the inverse permutation, indexed by item.

Return type:

RankVector

class RankVector(values)[source]

Bases: Sequence[int]

A permutation whose entry for each item is that item’s rank.

Parameters:

values (tuple[int, ...])

to_item_ordering()[source]

Return the inverse permutation, indexed by rank.

Return type:

ItemOrdering

item_ordering_to_rank_vector(value)[source]

Convert x[rank] = item to owned rank[item] = rank data.

Parameters:

value (Sequence[int] | ndarray | ItemOrdering)

Return type:

ndarray

rank_vector_to_item_ordering(value)[source]

Convert rank[item] = rank to owned x[rank] = item data.

Parameters:

value (Sequence[int] | ndarray | RankVector)

Return type:

ndarray