View Javadoc
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.statistics.ranking;
18  
19  /**
20   * Strategies for handling tied values in rank transformations.
21   *
22   * @since 1.1
23   */
24  public enum TiesStrategy {
25  
26      /**
27       * Ties are assigned ranks in order of occurrence in the original array.
28       *
29       * <p>For example, {@code [1, 3, 4, 3]} is ranked as {@code [1, 2, 4, 3]}.
30       */
31      SEQUENTIAL,
32  
33      /**
34       * Tied values are assigned the minimum applicable rank, or the rank of the
35       * first occurrence.
36       *
37       * <p>For example, {@code [1, 3, 4, 3]} is ranked as {@code [1, 2, 4, 2]}.
38       */
39      MINIMUM,
40  
41      /**
42       * Tied values are assigned the maximum applicable rank, or the rank of the last
43       * occurrence. <p>For example, {@code [1, 3, 4, 3]} is ranked as {@code [1, 3, 4, 3]}.
44       */
45      MAXIMUM,
46  
47      /**
48       * Tied values are assigned the average of the applicable ranks.
49       *
50       * <p>For example, {@code [1, 3, 4, 3]} is ranked as {@code [1, 2.5, 4, 2.5]}.
51       */
52      AVERAGE,
53  
54      /**
55       * Tied values are assigned a <em>unique</em> random integral rank from among the
56       * applicable values.
57       *
58       * <p>For example, {@code [1, 3, 4, 3]} is ranked as either {@code [1, 2, 4, 3]} or
59       * {@code [1, 3, 4, 2]} where the choice is random.
60       *
61       * <p>The assigned rank will always be an integer, (inclusively) between the
62       * values returned by the {@link #MINIMUM} and {@link #MAXIMUM} strategies.
63       *
64       * <p>Use of a <em>unique</em> rank ensures that ties are resolved so that the
65       * rank order is stable.
66       */
67      RANDOM
68  }