Package gpl.whiten
Class InfiniteSort
java.lang.Object
gpl.whiten.InfiniteSort
- Direct Known Subclasses:
InfiniteSortWithMean2
Class to conduct an infinite sort of data. That is a finite amount of data are sorted, but
as PAMGuard processes, one sample is added in and one taken out at each iteration. Therefore
after the initial sorting of the data, it's relatively fast to just find the position of
each new data point.
- Author:
- Doug Gillespie
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
addData
(double d) Add data to the sorted list.boolean
int
double
Get a mean value about the central tendency of the data.double
getCentralMean
(int usedPoints, int nMean) Get a mean value about the central tendency of the data.double[]
getData()
Array of data values.double
int
The number of points in the sortdouble
getSortedData
(int sortPosition) Get a single value at a specific sorted position.int[]
Sort order of the data.int
static void
void
setAutoInitialise
(int autoInitialise) void
setStop
(int i)
-
Constructor Details
-
InfiniteSort
public InfiniteSort(int nPoints)
-
-
Method Details
-
addData
public double addData(double d) Add data to the sorted list. The oldest data point will drop off the list and the correct index of the new data point will be found. Data are always left in place (unsorted) in the data list and modifications are only to the sorted index data.- Parameters:
d
- New data value.- Returns:
- the value of the data removed from the list (i.e. the oldest value)
-
checkSort
public boolean checkSort() -
getMedian
public double getMedian()- Returns:
- The median value from the sorted data.
-
getCentralMean
public double getCentralMean()Get a mean value about the central tendency of the data. This function first searches for the 50% of bins of data which are the most similar, then takes the mean of the data within that range.- Returns:
- Mean value about the central tendency.
-
getCentralMean
public double getCentralMean(int usedPoints, int nMean) Get a mean value about the central tendency of the data. This function first searches for the nMean bins of data which are the most similar, then takes the mean of the data within that range.- Parameters:
nMean
- Number of bins to calculate over. Must be invalid input: '<'= nPoints- Returns:
- Mean value about the central tendency.
-
getData
public double[] getData()Array of data values. Note that these remain unsorted. The oldest data will be at index 0 and the latest at index (nPoints-1)- Returns:
- the data
-
getSortedData
public double getSortedData(int sortPosition) Get a single value at a specific sorted position.- Parameters:
sortPosition
- sort position- Returns:
- data value for that index.
-
getSortInd
public int[] getSortInd()Sort order of the data. Data themselves are left in their original unsorted order, so these indexes are used to get data in the correct order, i.e. data[sortInd[0]] will be the data having the lowest value and data[sortind[nPoints-1]] will be the data having the highest value.- Returns:
- the sortIndexes
-
getnPoints
public int getnPoints()The number of points in the sort- Returns:
- the nPoints
-
setStop
public void setStop(int i) -
getAutoInitialise
public int getAutoInitialise()- Returns:
- the autoInitialise
-
setAutoInitialise
public void setAutoInitialise(int autoInitialise) - Parameters:
autoInitialise
- the autoInitialise to set
-
main
-
getTotalCalls
public int getTotalCalls()- Returns:
- the totalCalls
-