TiesStrategy.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */

  17. package org.apache.commons.math4.legacy.stat.ranking;

  18. /**
  19.  * Strategies for handling tied values in rank transformations.
  20.  * <ul>
  21.  * <li>SEQUENTIAL - Ties are assigned ranks in order of occurrence in the original array,
  22.  * for example (1,3,4,3) is ranked as (1,2,4,3)</li>
  23.  * <li>MINIMUM - Tied values are assigned the minimum applicable rank, or the rank
  24.  * of the first occurrence. For example, (1,3,4,3) is ranked as (1,2,4,2)</li>
  25.  * <li>MAXIMUM - Tied values are assigned the maximum applicable rank, or the rank
  26.  * of the last occurrence. For example, (1,3,4,3) is ranked as (1,3,4,3)</li>
  27.  * <li>AVERAGE - Tied values are assigned the average of the applicable ranks.
  28.  * For example, (1,3,4,3) is ranked as (1,2.5,4,2.5)</li>
  29.  * <li>RANDOM - Tied values are assigned a random integer rank from among the
  30.  * applicable values. The assigned rank will always be an integer, (inclusively)
  31.  * between the values returned by the MINIMUM and MAXIMUM strategies.</li>
  32.  * </ul>
  33.  *
  34.  * @since 2.0
  35.  */
  36. public enum TiesStrategy {

  37.     /** Ties assigned sequential ranks in order of occurrence. */
  38.     SEQUENTIAL,

  39.     /** Ties get the minimum applicable rank. */
  40.     MINIMUM,

  41.     /** Ties get the maximum applicable rank. */
  42.     MAXIMUM,

  43.     /** Ties get the average of applicable ranks. */
  44.     AVERAGE,

  45.     /** Ties get a random integral value from among applicable ranks. */
  46.     RANDOM
  47. }