Class Median
- java.lang.Object
-
- org.hipparchus.stat.descriptive.AbstractUnivariateStatistic
-
- org.hipparchus.stat.descriptive.rank.Median
-
- All Implemented Interfaces:
Serializable,UnivariateStatistic,MathArrays.Function
public class Median extends AbstractUnivariateStatistic implements Serializable
Returns the median of the available values. This is the same as the 50th percentile. SeePercentilefor 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()orclear()method, it must be synchronized externally.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Median()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mediancopy()Returns a copy of the statistic with the same internal state.doubleevaluate(double[] values, int begin, int length)Returns the result of evaluating the statistic over the specified entries in the input array.Percentile.EstimationTypegetEstimationType()Get the estimationtypeused for computation.KthSelectorgetKthSelector()Get thekthSelectorused for computation.NaNStrategygetNaNStrategy()Get theNaN Handlingstrategy used for computation.MedianwithEstimationType(Percentile.EstimationType newEstimationType)Build a new instance similar to the current one except for theestimation type.MedianwithKthSelector(KthSelector newKthSelector)Build a new instance similar to the current one except for thekthSelectorinstance specifically set.MedianwithNaNStrategy(NaNStrategy newNaNStrategy)Build a new instance similar to the current one except for theNaN handlingstrategy.-
Methods inherited from class org.hipparchus.stat.descriptive.AbstractUnivariateStatistic
evaluate, getData, getDataRef, setData, setData
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hipparchus.stat.descriptive.UnivariateStatistic
evaluate
-
-
-
-
Method Detail
-
evaluate
public double evaluate(double[] values, int begin, int length) throws MathIllegalArgumentExceptionReturns the result of evaluating the statistic over the specified entries in the input array.- Specified by:
evaluatein interfaceMathArrays.Function- Specified by:
evaluatein interfaceUnivariateStatistic- Specified by:
evaluatein classAbstractUnivariateStatistic- Parameters:
values- the input arraybegin- the index of the first element to includelength- the number of elements to include- Returns:
- the value of the statistic applied to the included array entries
- Throws:
MathIllegalArgumentException- if values is null or the indices are invalid
-
copy
public Median copy()
Returns a copy of the statistic with the same internal state.- Specified by:
copyin interfaceUnivariateStatistic- Specified by:
copyin classAbstractUnivariateStatistic- Returns:
- a copy of the statistic
-
getEstimationType
public Percentile.EstimationType getEstimationType()
Get the estimationtypeused for computation.- Returns:
- the
estimationTypeset
-
withEstimationType
public Median withEstimationType(Percentile.EstimationType newEstimationType)
Build a new instance similar to the current one except for theestimation type.- Parameters:
newEstimationType- estimation type for the new instance- Returns:
- a new instance, with changed estimation type
- Throws:
NullArgumentException- when newEstimationType is null
-
getNaNStrategy
public NaNStrategy getNaNStrategy()
Get theNaN Handlingstrategy used for computation.- Returns:
NaN Handlingstrategy set during construction
-
withNaNStrategy
public Median withNaNStrategy(NaNStrategy newNaNStrategy)
Build a new instance similar to the current one except for theNaN handlingstrategy.- Parameters:
newNaNStrategy- NaN strategy for the new instance- Returns:
- a new instance, with changed NaN handling strategy
- Throws:
NullArgumentException- when newNaNStrategy is null
-
getKthSelector
public KthSelector getKthSelector()
Get thekthSelectorused for computation.- Returns:
- the
kthSelectorset
-
withKthSelector
public Median withKthSelector(KthSelector newKthSelector)
Build a new instance similar to the current one except for thekthSelectorinstance specifically set.- Parameters:
newKthSelector- KthSelector for the new instance- Returns:
- a new instance, with changed KthSelector
- Throws:
NullArgumentException- when newKthSelector is null
-
-