Package org.hipparchus.util
Class KthSelector
java.lang.Object
org.hipparchus.util.KthSelector
- All Implemented Interfaces:
Serializable
A Simple Kth selector implementation to pick up the
Kth ordered element from a work array containing the
input numbers.
- See Also:
-
Constructor Summary
ConstructorDescriptionConstructor with defaultmedian of 3
pivoting strategy.KthSelector
(PivotingStrategy pivotingStrategy) Constructor with specified pivoting strategy -
Method Summary
Modifier and TypeMethodDescriptionGet the pivoting strategy.double
select
(double[] work, int[] pivotsHeap, int k) Select Kth value in the array.
-
Constructor Details
-
KthSelector
public KthSelector()Constructor with defaultmedian of 3
pivoting strategy. -
KthSelector
Constructor with specified pivoting strategy- Parameters:
pivotingStrategy
- pivoting strategy to use- Throws:
NullArgumentException
- when pivotingStrategy is null
-
-
Method Details
-
getPivotingStrategy
Get the pivoting strategy.- Returns:
- pivoting strategy
-
select
public double select(double[] work, int[] pivotsHeap, int k) Select Kth value in the array.- Parameters:
work
- work array to use to find out the Kth valuepivotsHeap
- cached pivots heap that can be used for efficient estimationk
- the index whose value in the array is of interest- Returns:
- Kth value
-