public class QuickSelect extends Object
Modifier and Type | Field and Description |
---|---|
private static int |
SMALL
For small arrays, use a simpler method:
|
Constructor and Description |
---|
QuickSelect() |
Modifier and Type | Method and Description |
---|---|
private static void |
insertionSort(double[] data,
int start,
int end)
Sort a small array using repetitive insertion sort.
|
static double |
median(double[] data)
Compute the median of an array efficiently using the QuickSelect method.
|
static double |
median(double[] data,
int begin,
int end)
Compute the median of an array efficiently using the QuickSelect method.
|
static double |
quantile(double[] data,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static double |
quantile(double[] data,
int begin,
int end,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static double |
quickSelect(double[] data,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
static void |
quickSelect(double[] data,
int start,
int end,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
private static void |
swap(double[] data,
int a,
int b)
The usual swap method.
|
private static final int SMALL
public static double quickSelect(double[] data, int rank)
data
- Data to processrank
- Rank position that we are interested in (integer!)public static double median(double[] data)
data
- Data to processpublic static double median(double[] data, int begin, int end)
data
- Data to processbegin
- Begin of valid valuesend
- End of valid values (inclusive!)public static double quantile(double[] data, double quant)
data
- Data to processquant
- Quantile to computepublic static double quantile(double[] data, int begin, int end, double quant)
data
- Data to processbegin
- Begin of valid valuesend
- End of valid values (inclusive!)quant
- Quantile to computepublic static void quickSelect(double[] data, int start, int end, int rank)
data
- Data to processstart
- Interval startend
- Interval end (inclusive)rank
- rank position we are interested in (starting at 0)private static void insertionSort(double[] data, int start, int end)
data
- Data to sortstart
- Interval startend
- Interval endprivate static final void swap(double[] data, int a, int b)
data
- Arraya
- First indexb
- Second index