Skip to content

RankTies

RankTies module-attribute

RankTies: TypeAlias = Literal[
    "average", "min", "max", "dense"
]

How tokens sharing a frequency are ranked.

Tokens of equal frequency form a tie block, and every method keeps that block together at a single shared rank. In the frequencies [10, 5, 5, 5, 1], the three 5s form one tie block.

  • "average" gives the block the mean of the ranks it spans. In the example, this produces rank 3.
  • "min" gives the block the first of the ranks it spans. In the example, this produces rank 2.
  • "max" gives the block the last of the ranks it spans. In the example, this produces rank 4.
  • "dense" numbers the distinct frequencies rather than the tokens, so a tie block takes up one rank instead of as many ranks as it has tokens. In the example, this produces rank 2 for the block and rank 3 for the 1, where the other three methods leave the 1 at rank 5.

Source