A.rank( y )

Read(376) Label: members, ranking,

Description:

Compute the ranking of a specified value in a sequence.

Syntax:

A.rank(y)

Note:

The function returns the ranking of a specified value y in sequence A, which by default is sorted in ascending order.

Options:

@z

Return a ranking according to members sorted in descending order. Here “z” is in lowercase.

@i

Deduplicate sequence A before getting y’s ranking.

@s

Perform average operation for each of the duplicate ranking and return the result, which could contain non-integers. Take the sequence [3,2,6,6,9] for example, a default ranking is [2,1,3,3,5]; but with @s option, the ranking becomes [2.0,1.0,(3+4)/2,(3+4)/2,5.0] after we get averages for the two duplicates.

Parameters:

A

A sequence

y

A member of sequence A

Return value:

An integer sequence composed of rankings of sequence A’s members

Example:

 

A

 

1

=[2,1,3,4,8,5,2,0]

 

2

=A1.rank(6)

8; a ranking according to ascendingly ordered members

3

=A1.rank@z(6)

2; a ranking according to descendingly ordered members

4

=A1.rank@i(2)

3; deduplicate the sequence before finding the ranking

5

=A1.rank@s(2)

3.5; get averages for duplicate rankings and then return the final result

Related functions:

A.rank(y,x)