All Implemented Interfaces:
Serializable, UnivariateStatistic, MathArrays.Function

public class Median extends Percentile implements Serializable
Returns the median of the available values. This is the same as the 50th percentile. See Percentile for a description of the algorithm used.

Note that this implementation is not synchronized. If multiple threads access an instance of this class concurrently, and at least one of the threads invokes the increment() or clear() method, it must be synchronized externally.

See Also:
  • Constructor Details

    • Median

      public Median()
      Default constructor.
    • Median

      public Median(Median original) throws NullArgumentException
      Copy constructor, creates a new Median identical to the original
      Parameters:
      original - the Median instance to copy
      Throws:
      NullArgumentException - if original is null
  • Method Details

    • withEstimationType

      public Median withEstimationType(Percentile.EstimationType newEstimationType)
      Build a new instance similar to the current one except for the estimation type.

      This method is intended to be used as part of a fluent-type builder pattern. Building finely tune instances should be done as follows:

         Percentile customized = new Percentile(quantile).
                                 withEstimationType(estimationType).
                                 withNaNStrategy(nanStrategy).
                                 withKthSelector(kthSelector);
       

      If any of the withXxx method is omitted, the default value for the corresponding customization parameter will be used.

      Overrides:
      withEstimationType in class Percentile
      Parameters:
      newEstimationType - estimation type for the new instance
      Returns:
      a new instance, with changed estimation type
    • withNaNStrategy

      public Median withNaNStrategy(NaNStrategy newNaNStrategy)
      Build a new instance similar to the current one except for the NaN handling strategy.

      This method is intended to be used as part of a fluent-type builder pattern. Building finely tune instances should be done as follows:

         Percentile customized = new Percentile(quantile).
                                 withEstimationType(estimationType).
                                 withNaNStrategy(nanStrategy).
                                 withKthSelector(kthSelector);
       

      If any of the withXxx method is omitted, the default value for the corresponding customization parameter will be used.

      Overrides:
      withNaNStrategy in class Percentile
      Parameters:
      newNaNStrategy - NaN strategy for the new instance
      Returns:
      a new instance, with changed NaN handling strategy
    • withKthSelector

      public Median withKthSelector(KthSelector newKthSelector)
      Build a new instance similar to the current one except for the kthSelector instance specifically set.

      This method is intended to be used as part of a fluent-type builder pattern. Building finely tune instances should be done as follows:

         Percentile customized = new Percentile(quantile).
                                 withEstimationType(estimationType).
                                 withNaNStrategy(nanStrategy).
                                 withKthSelector(newKthSelector);
       

      If any of the withXxx method is omitted, the default value for the corresponding customization parameter will be used.

      Overrides:
      withKthSelector in class Percentile
      Parameters:
      newKthSelector - KthSelector for the new instance
      Returns:
      a new instance, with changed KthSelector