Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "stats/ranks/docs/types/index.d"

Index

Interfaces

Functions

Functions

Export assignment ranks

  • Computes the sample ranks for the values of an array-like object.

    Notes

    • When all elements of the array are different, the ranks are uniquely determined. When there are equal elements (called ties), the method option determines how they are handled. The default, 'average', replaces the ranks of the ties by their mean. Other possible options are 'min' and 'max', which replace the ranks of the ties by their minimum and maximum, respectively. 'dense' works like 'min', with the difference that the next highest element after a tie is assigned the next smallest integer. Finally, ordinal gives each element in arr a distinct rank, according to the position they appear in.
    • The missing option is used to specify how to handle missing data. By default, NaN or null are treated as missing values. 'last'specifies that missing values are placed last, 'first' that the are assigned the lowest ranks and 'remove' means that they are removed from the array before the ranks are calculated.
    throws

    must provide valid options

    Parameters

    Returns Array < number >

    array containing the computed ranks for the elements of x

    Example

    var arr = [ 1.1, 2.0, 3.5, 0.0, 2.4 ];
    var out = ranks( arr );
    // returns [ 2, 3, 5, 1, 4 ]

    Example

    // Ties are averaged:
    arr = [ 2, 2, 1, 4, 3 ];
    out = ranks( arr );
    // returns [ 2.5, 2.5, 1, 5, 4 ]

    Example

    // Missing values are placed last:
    arr = [ null, 2, 2, 1, 4, 3, NaN, NaN ];
    out = ranks( arr );
    // returns [ 6, 2.5, 2.5, 1, 5, 4, 7 ,8 ]