This site is supported by donations to The OEIS Foundation.

Template:Rank item

From OeisWiki
Jump to: navigation, search

The {{rank item}} mathematical function template gives a 1-indexed numerical ranking (from lowest to highest) of the list item with a given index within a list of up to 64 items. When there are duplicates, each set of duplicates are given the same ranking, and the ranking corresponds to the highest ranking one would get if the rankings were consecutive integers.

Usage

{{rank item|index|num_expr_1}}

up to

{{rank item|index|num_expr_1|...|num_expr_64}}

where

  • index is a numerical expression yielding an integer from 1 to index of last item of the item to rank in the provided list of up to 64 items;
  • num_expr_1 to num_expr_64 are numerical expressions yielding real numbers.

Examples

{{rank item}} yields Rank item error: the first argument must be an expression giving the index [1 to index of last item] of the item to rank in the provided list of up to 64 items.


{{rank|14|4|7|1|-8|16|0|-25}} yields (7, 5, 6, 4, 2, 8, 3, 1)
{{rank item|1|14|4|7|1|-8|16|0|-25}} yields 7
{{rank item|2|14|4|7|1|-8|16|0|-25}} yields 5
{{rank item|3|14|4|7|1|-8|16|0|-25}} yields 6
{{rank item|4|14|4|7|1|-8|16|0|-25}} yields 4
{{rank item|5|14|4|7|1|-8|16|0|-25}} yields 2
{{rank item|6|14|4|7|1|-8|16|0|-25}} yields 8
{{rank item|2*3|14|4|7|1|-8|16|0|-25}} yields 8
{{rank item|7|14|4|7|1|-8|16|0|-25}} yields 3
{{rank item|8|14|4|7|1|-8|16|0|-25}} yields 1
{{rank item|2^3|14|4|7|1|-8|16|0|-25}} yields 1


{{rank item|9|14|4|7|1|-8|16|0|-25}} yields Rank item error: the first argument must be an expression giving the index [1 to index of last item] of the item to rank in the provided list of up to 64 items.
{{rank item|0|14|4|7|1|-8|16|0|-25}} yields Rank item error: the first argument must be an expression giving the index [1 to index of last item] of the item to rank in the provided list of up to 64 items.
{{rank item|5.5|14|4|7|1|-8|16|0|-25}} yields Rank item error: the first argument must be an expression giving the index [1 to index of last item] of the item to rank in the provided list of up to 64 items.
{{rank item|-8|14|4|7|1|-8|16|0|-25}} yields Rank item error: the first argument must be an expression giving the index [1 to index of last item] of the item to rank in the provided list of up to 64 items.


{{rank|14|4|7|1|-8|16|0|-25|143|17|69|34|55|-47|15|-52}} yields (9, 7, 8, 6, 4, 11, 5, 3, 16, 12, 15, 13, 14, 2, 10, 1)
{{rank item|10|14|4|7|1|-8|16|0|-25|143|17|69|34|55|-47|15|-52}} yields 12
{{rank item|2*5|2*7|2^2|2*3 + 1|1|(-2)^3|2^4|0|-(5^2)|11*13|34/2|3*23|2*17|5*11|(-1)*47|3*5|-(2^2 * 13)}} yields 12
{{rank item|10|14|4|7|1|-8|16|0|-25|143|17|69|34|55|-47|15|-52|-777}} yields 13
{{rank item|2*5|2*7|2^2|2*3 + 1|1|(-2)^3|2^4|0|-(5^2)|11*13|34/2|3*23|2*17|5*11|(-1)*47|3*5|-(2^2 * 13)|-777}} yields 13


With the 59 terms from A030640

{{rank item|12|1|1|-3|-2|5|3|-7|-4|9|5|-11|-6|13|7|-15|-8|17|9|-19|-10|21|11|-23|-12|25|13|-27|-14|29|15|-31|-16|33|17|-35|-18|37|19|-39|-20|41|21|-43|-22|45|23|-47|-24|49|25|-51|-26|53|27|-55|-28|57|29|-59}} yields 26

after using

: {{#replace: {{#replace: 1, 1, -3, -2, 5, 3, -7, -4, 9, 5, -11, -6, 13, 7, -15, -8, 17, 9, -19, -10, 21, 11, -23, -12, 25, 13, -27, -14, 29, 15, -31, -16, 33, 17, -35, -18, 37, 19, -39, -20, 41, 21, -43, -22, 45, 23, -47, -24, 49, 25, -51, -26, 53, 27, -55, -28, 57, 29, -59|}}|,|{{!}}}}

to get

1|1|-3|-2|5|3|-7|-4|9|5|-11|-6|13|7|-15|-8|17|9|-19|-10|21|11|-23|-12|25|13|-27|-14|29|15|-31|-16|33|17|-35|-18|37|19|-39|-20|41|21|-43|-22|45|23|-47|-24|49|25|-51|-26|53|27|-55|-28|57|29|-59

Adding 5 more terms

{{rank item|12|1|1|-3|-2|5|3|-7|-4|9|5|-11|-6|13|7|-15|-8|17|9|-19|-10|21|11|-23|-12|25|13|-27|-14|29|15|-31|-16|33|17|-35|-18|37|19|-39|-20|41|21|-43|-22|45|23|-47|-24|49|25|-51|-26|53|27|-55|-28|57|29|-59|0|0|0|0|0}} yields 26

Adding 1 more term (one too many)

{{rank item|12|1|1|-3|-2|5|3|-7|-4|9|5|-11|-6|13|7|-15|-8|17|9|-19|-10|21|11|-23|-12|25|13|-27|-14|29|15|-31|-16|33|17|-35|-18|37|19|-39|-20|41|21|-43|-22|45|23|-47|-24|49|25|-51|-26|53|27|-55|-28|57|29|-59|0|0|0|0|0|0}} yields 26 Rank item error: only the first 64 list items [list items 1 to 64 given in arguments 2 to 65] are considered!

Examples with duplicates

{{rank|-8|14|0|-25|14|4|0|1}} yields (2, 8, 4, 1, 8, 6, 4, 5)
{{rank item|3|-8|14|0|-25|14|4|0|1}} yields 4
{{rank|-8.2|14.1|0|-25.4|14.1|4|0|1}} yields (2, 8, 4, 1, 8, 6, 4, 5)
{{rank item|3|-8.2|14.1|0|-25.4|14.1|4|0|1}} yields 4