# Ranks from a sample written as a function

Can sample rank be defined as a function of a sample?

Suppose $$X_1, X_2, \dots X_n \sim F$$ where $$F$$ is defined on space $$\mathcal{X}$$. Consider the order statistics $$X_{(1)}, X_{(2)}, \dots, X_{(n)}$$. Then we know that rank of $$X_i$$ is $$R_i$$ if $$X_i = X_{(R_i)}$$. (I am assuming data are all different).

Is there any way to write rank as a function $$f: \mathcal{X}^n \to \{1, \dots, n\}$$?

• With data I always have to think about what ties imply. Fractional ranks are yielded by many rules. Perhaps you just want an abstract discussion based on an assumption that data should all be different. – Nick Cox Apr 30 '20 at 11:03
• Sorry, yes, assuming unique data points – Greenparker Apr 30 '20 at 11:07
• What distinction are you implying between a "function" and an "operator"? (In mathematics, both of them are functions and whether you call something an "operator" depends on the context, but usually means the domain of the operator is itself a set of functions.) – whuber Apr 30 '20 at 15:00
• @whuber I've removed the part about it being an operator. – Greenparker Apr 30 '20 at 15:06
• Okay, so a follow-up question is this: what do you mean by "write ... as a function"? Mathematics views functions as subsets of a cartesian product with certain properties (namely, there is at most one element in the codomain associated with each element in the domain), whereas other disciplines may think of them as formulas or algorithms or rules for computation, etc. I hope it's obvious that the rank of the $i^\text{th}$ component is a function in the mathematical sense when the vectors with tied values are removed from $\mathcal{X}^n$ but not a function on $\mathcal{X}^n$ itself. – whuber Apr 30 '20 at 19:02

Not sure if this helps, but assuming all data points are unique, then we can define the functions recursively

$$R_{1} = \min \Big\{ j \in \{1,\dots,n\} : X_j = \min (X_1, \dots, X_n) \Big\}$$

$$R_{2} = \min \Big\{ j \in \{1,\dots,n \} : X_j = \min (X_{(-1)}) \Big\}$$ $$\dots$$ $$R_i = \min \Big\{ j \in \{1,\dots,n \} : X_j = \min (X_{(-1,-2,\dots,-(i-1))}) \Big\}$$

Where $$X_{(-1,-2,\dots,-(i-1))}$$ is the datavector after removing $$X_{(1)},\dots,X_{(i-1)}$$, found using the prior defined rank functions for $$R_1, \dots, R_{(i-1)}$$.

While not exactly closed form, these functions are easily written in a program like R, if that's what your interested in doing.

Otherwise, more generally, we could write

$$R_i = \min \{j \in \{1,\dots,n\}: |\{k: X_k \leq X_j \}|=i \}$$

where $$|\cdot |$$ is set cardinality.