winsorize#

swordfish.function.winsorize()#

Return a winsorized version of the input array. For in-place modification, use winsorize.

Parameters:
  • X (Constant) – A vector.

  • limit (Constant) –

    A scalar or a vector with 2 elements indicating the percentages to cut on each side of X, with respect to the number of unmasked data, as floats between 0 and 1, by default DFLT.

    • If limit is a scalar, it means the percentages to cut on both sides of X.

    • If limit has n elements (including null values), the (n * limit[0])-th smallest element and the (n * limit[1])-th largest element are masked, and the total number of unmasked data after trimming is n * (1-sum(limit)). The value of one element of limit can be set to 0 to indicate no masking is conducted on this side.

  • inclusive (Constant, optional) – A Boolean type scalar or a vector of 2 elements indicating whether the number of data being masked on each side should be truncated (true) or rounded (false)

  • nanPolicy (Constant, optional) –

    A string indicating how to handle null values, by default DFLT. The following options are available (default is ‘upper’):

    • ’upper’: allows null values and treats them as the largest values of X.

    • ’lower’: allows null values and treats them as the smallest values of X.

    • ’raise’: throws an error.

    • ’omit’: performs the calculations without masking null values.