mpercentileTopN#

swordfish.function.mpercentileTopN()#
  • When X is a vector, within a sliding window of given length (measured by the number of elements), the function stably sorts X by S in the order specified by ascending, then calculates the moving percentile rank of the first top elements.

  • When X is a matrix or table, conduct the aforementioned calculation within each column of X. The result is a matrix/table with the same shape as X.

Parameters:
  • X (Constant) – A numeric vector, matrix or table.

  • S (Constant) – A numeric/temporal vector, matrix or table, based on which X are sorted.

  • percent (Constant) – An integer or floating value between 0 and 100.

  • interpolation (Constant, optional) –

    A string indicating the interpolation method to use if the specified percentile is between two elements in X (assuming the \(i^{th}\) and \((i+1)^{th}\) element in the sorted X). It can take the following values:

    • ’linear’(default): Return \(X_i+(X_{i+1}-X_i) * fraction\), where \(fraction=\frac{percentile/100-i/(size-1)}{1/(size-1)}\)

    • ’lower’: Return \(X_i\)

    • ’higher’: Return \(X_{i+1}\)

    • ’nearest’: Return \(X_{i+1}\) or \(X_i\) that is closest to the specified percentile

    • ’midpoint’: Return \(X_i\)