Enum Percentile.EstimationType

java.lang.Object
java.lang.Enum<Percentile.EstimationType>
org.hipparchus.stat.descriptive.rank.Percentile.EstimationType
All Implemented Interfaces:
Serializable, Comparable<Percentile.EstimationType>, java.lang.constant.Constable
Enclosing class:
Percentile

public static enum Percentile.EstimationType extends Enum<Percentile.EstimationType>
An enum for various estimation strategies of a percentile referred in wikipedia on quantile with the names of enum matching those of types mentioned in wikipedia.

Each enum corresponding to the specific type of estimation in wikipedia implements the respective formulae that specializes in the below aspects

  • An index method to calculate approximate index of the estimate
  • An estimate method to estimate a value found at the earlier computed index
  • A minLimit on the quantile for which first element of sorted input is returned as an estimate
  • A maxLimit on the quantile for which last element of sorted input is returned as an estimate

Users can now create Percentile by explicitly passing this enum; such as by invoking Percentile.withEstimationType(EstimationType)

References:

  1. Wikipedia on quantile
  2. Hyndman, R. J. and Fan, Y. (1996) Sample quantiles in statistical packages, American Statistician 50, 361–365
  3. R-Manual
  • Nested Class Summary Link icon

    Nested classes/interfaces inherited from class java.lang.Enum Link icon

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary Link icon

    Enum Constants
    Enum Constant
    Description
    This is the default type used in the Percentile.This method has the following formulae for index and estimates
    index=(N+1)p estimate=xh1/2minLimit=0maxLimit=1
    The method R_1 has the following formulae for index and estimates
    index=Np+1/2estimate=xh1/2minLimit=0
    The method R_2 has the following formulae for index and estimates
    index=Np+1/2estimate=xh1/2+xh+1/22minLimit=0maxLimit=1
    The method R_3 has the following formulae for index and estimates
    index=Npestimate=xhminLimit=0.5/N
    The method R_4 has the following formulae for index and estimates
    index=Npestimate=xh+(hh)(xh+1xh)minLimit=1/NmaxLimit=1
    The method R_5 has the following formulae for index and estimates
    index=Np+1/2estimate=xh+(hh)(xh+1xh)minLimit=0.5/NmaxLimit=(N0.5)/N
    The method R_6 has the following formulae for index and estimates
    index=(N+1)pestimate=xh+(hh)(xh+1xh)minLimit=1/(N+1)maxLimit=N/(N+1)
    The method R_7 implements Microsoft Excel style computation has the following formulae for index and estimates.
    index=(N1)p+1estimate=xh+(hh)(xh+1xh)minLimit=0maxLimit=1
    The method R_8 has the following formulae for index and estimates
    index=(N+1/3)p+1/3estimate=xh+(hh)(xh+1xh)minLimit=(2/3)/(N+1/3)maxLimit=(N1/3)/(N+1/3)
    The method R_9 has the following formulae for index and estimates
    index=(N+1/4)p+3/8estimate=xh+(hh)(xh+1xh)minLimit=(5/8)/(N+1/4)maxLimit=(N3/8)/(N+1/4)
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    protected double
    estimate(double[] work, int[] pivotsHeap, double pos, int length, KthSelector selector)
    Estimation based on Kth selection.
    double
    evaluate(double[] work, double p, KthSelector selector)
    Evaluate method to compute the percentile for a given bounded array.
    protected double
    evaluate(double[] work, int[] pivotsHeap, double p, KthSelector selector)
    Evaluate method to compute the percentile for a given bounded array using earlier computed pivots heap.
    This basically calls the index and then estimate functions to return the estimated percentile value.
    protected abstract double
    index(double p, int length)
    Finds the index of array that can be used as starting index to estimate percentile.
    Returns the enum constant of this type with the specified name.
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Object Link icon

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details Link icon

    • LEGACY Link icon

      public static final Percentile.EstimationType LEGACY
      This is the default type used in the Percentile.This method has the following formulae for index and estimates
      index=(N+1)p estimate=xh1/2minLimit=0maxLimit=1
    • R_1 Link icon

      public static final Percentile.EstimationType R_1
      The method R_1 has the following formulae for index and estimates
      index=Np+1/2estimate=xh1/2minLimit=0
    • R_2 Link icon

      public static final Percentile.EstimationType R_2
      The method R_2 has the following formulae for index and estimates
      index=Np+1/2estimate=xh1/2+xh+1/22minLimit=0maxLimit=1
    • R_3 Link icon

      public static final Percentile.EstimationType R_3
      The method R_3 has the following formulae for index and estimates
      index=Npestimate=xhminLimit=0.5/N
    • R_4 Link icon

      public static final Percentile.EstimationType R_4
      The method R_4 has the following formulae for index and estimates
      index=Npestimate=xh+(hh)(xh+1xh)minLimit=1/NmaxLimit=1
    • R_5 Link icon

      public static final Percentile.EstimationType R_5
      The method R_5 has the following formulae for index and estimates
      index=Np+1/2estimate=xh+(hh)(xh+1xh)minLimit=0.5/NmaxLimit=(N0.5)/N
    • R_6 Link icon

      public static final Percentile.EstimationType R_6
      The method R_6 has the following formulae for index and estimates
      index=(N+1)pestimate=xh+(hh)(xh+1xh)minLimit=1/(N+1)maxLimit=N/(N+1)

      Note: This method computes the index in a manner very close to the default Hipparchus Percentile existing implementation. However the difference to be noted is in picking up the limits with which first element (p<1(N+1)) and last elements (p>N/(N+1))are done. While in default case; these are done with p=0 and p=1 respectively.

    • R_7 Link icon

      public static final Percentile.EstimationType R_7
      The method R_7 implements Microsoft Excel style computation has the following formulae for index and estimates.
      index=(N1)p+1estimate=xh+(hh)(xh+1xh)minLimit=0maxLimit=1
    • R_8 Link icon

      public static final Percentile.EstimationType R_8
      The method R_8 has the following formulae for index and estimates
      index=(N+1/3)p+1/3estimate=xh+(hh)(xh+1xh)minLimit=(2/3)/(N+1/3)maxLimit=(N1/3)/(N+1/3)

      As per Ref [2,3] this approach is most recommended as it provides an approximate median-unbiased estimate regardless of distribution.

    • R_9 Link icon

      public static final Percentile.EstimationType R_9
      The method R_9 has the following formulae for index and estimates
      index=(N+1/4)p+3/8estimate=xh+(hh)(xh+1xh)minLimit=(5/8)/(N+1/4)maxLimit=(N3/8)/(N+1/4)
  • Method Details Link icon

    • values Link icon

      public static Percentile.EstimationType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf Link icon

      public static Percentile.EstimationType valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • index Link icon

      protected abstract double index(double p, int length)
      Finds the index of array that can be used as starting index to estimate percentile. The calculation of index calculation is specific to each Percentile.EstimationType.
      Parameters:
      p - the pth quantile
      length - the total number of array elements in the work array
      Returns:
      a computed real valued index as explained in the wikipedia
    • estimate Link icon

      protected double estimate(double[] work, int[] pivotsHeap, double pos, int length, KthSelector selector)
      Estimation based on Kth selection. This may be overridden in specific enums to compute slightly different estimations.
      Parameters:
      work - array of numbers to be used for finding the percentile
      pivotsHeap - an earlier populated cache if exists; will be used
      pos - indicated positional index prior computed from calling index(double, int)
      length - size of array considered
      selector - a KthSelector used for pivoting during search
      Returns:
      estimated percentile
    • evaluate Link icon

      protected double evaluate(double[] work, int[] pivotsHeap, double p, KthSelector selector)
      Evaluate method to compute the percentile for a given bounded array using earlier computed pivots heap.
      This basically calls the index and then estimate functions to return the estimated percentile value.
      Parameters:
      work - array of numbers to be used for finding the percentile
      pivotsHeap - a prior cached heap which can speed up estimation
      p - the pth quantile to be computed
      selector - a KthSelector used for pivoting during search
      Returns:
      estimated percentile
      Throws:
      MathIllegalArgumentException - if p is out of range
      NullArgumentException - if work array is null
    • evaluate Link icon

      public double evaluate(double[] work, double p, KthSelector selector)
      Evaluate method to compute the percentile for a given bounded array. This basically calls the index and then estimate functions to return the estimated percentile value. Please note that this method does not make use of cached pivots.
      Parameters:
      work - array of numbers to be used for finding the percentile
      p - the pth quantile to be computed
      selector - a KthSelector used for pivoting during search
      Returns:
      estimated percentile
      Throws:
      MathIllegalArgumentException - if length or p is out of range
      NullArgumentException - if work array is null