Class Median

  • All Implemented Interfaces:
    Serializable, UnivariateStatistic, org.hipparchus.util.MathArrays.Function

    public class Median
    extends AbstractUnivariateStatistic
    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:
    Serialized Form
    • Constructor Detail

      • Median

        public Median()
        Default constructor.
    • Method Detail

      • evaluate

        public double evaluate​(double[] values,
                               int begin,
                               int length)
                        throws org.hipparchus.exception.MathIllegalArgumentException
        Returns the result of evaluating the statistic over the specified entries in the input array.
        Specified by:
        evaluate in interface org.hipparchus.util.MathArrays.Function
        Specified by:
        evaluate in interface UnivariateStatistic
        Specified by:
        evaluate in class AbstractUnivariateStatistic
        Parameters:
        values - the input array
        begin - the index of the first element to include
        length - the number of elements to include
        Returns:
        the value of the statistic applied to the included array entries
        Throws:
        org.hipparchus.exception.MathIllegalArgumentException - if values is null or the indices are invalid
      • getEstimationType

        public Percentile.EstimationType getEstimationType()
        Get the estimation type used for computation.
        Returns:
        the estimationType set
      • withEstimationType

        public Median withEstimationType​(Percentile.EstimationType newEstimationType)
        Build a new instance similar to the current one except for the estimation type.
        Parameters:
        newEstimationType - estimation type for the new instance
        Returns:
        a new instance, with changed estimation type
        Throws:
        org.hipparchus.exception.NullArgumentException - when newEstimationType is null
      • getNaNStrategy

        public NaNStrategy getNaNStrategy()
        Get the NaN Handling strategy used for computation.
        Returns:
        NaN Handling strategy set during construction
      • withNaNStrategy

        public Median withNaNStrategy​(NaNStrategy newNaNStrategy)
        Build a new instance similar to the current one except for the NaN handling strategy.
        Parameters:
        newNaNStrategy - NaN strategy for the new instance
        Returns:
        a new instance, with changed NaN handling strategy
        Throws:
        org.hipparchus.exception.NullArgumentException - when newNaNStrategy is null
      • getKthSelector

        public org.hipparchus.util.KthSelector getKthSelector()
        Get the kthSelector used for computation.
        Returns:
        the kthSelector set
      • withKthSelector

        public Median withKthSelector​(org.hipparchus.util.KthSelector newKthSelector)
        Build a new instance similar to the current one except for the kthSelector instance specifically set.
        Parameters:
        newKthSelector - KthSelector for the new instance
        Returns:
        a new instance, with changed KthSelector
        Throws:
        org.hipparchus.exception.NullArgumentException - when newKthSelector is null