Package uk.ac.starlink.ttools.filter
Class SortQuantiler
java.lang.Object
uk.ac.starlink.ttools.filter.SortQuantiler
- All Implemented Interfaces:
Quantiler
Quantiler that retains all data samples, sorts them when ready,
and uses the sorted array to answer questions about quantiles.
This is exact, but consumes approximately 8 bytes per sample,
so not suited for unlimited sized datasets.
- Since:
- 3 Dec 2020
- Author:
- Mark Taylor
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with default block size.SortQuantiler(int blocksize) Constructor with supplied block size. -
Method Summary
Modifier and TypeMethodDescriptionvoidacceptDatum(double value) Accepts a value to accumulate for quantile calculations.voidMerges the state of another compatible accumulator into this one; the effect is as if all theQuantiler.acceptDatum(double)calls that were made onotherhad been made on this one.doublegetValueAtQuantile(double quantile) Returns the value at a given quantile.voidready()Call after all data has been accumulated and before quantiles are to be calculated.
-
Field Details
-
DFLT_BLOCKSIZE
public static final int DFLT_BLOCKSIZEDefault block size.- See Also:
-
-
Constructor Details
-
SortQuantiler
public SortQuantiler()Constructor with default block size. -
SortQuantiler
public SortQuantiler(int blocksize) Constructor with supplied block size.- Parameters:
blocksize- tuning parameter, block size in bytes
-
-
Method Details
-
acceptDatum
public void acceptDatum(double value) Description copied from interface:QuantilerAccepts a value to accumulate for quantile calculations. NaN values are ignored.- Specified by:
acceptDatumin interfaceQuantiler- Parameters:
value- value to accumulate
-
addQuantiler
Description copied from interface:QuantilerMerges the state of another compatible accumulator into this one; the effect is as if all theQuantiler.acceptDatum(double)calls that were made onotherhad been made on this one.- Specified by:
addQuantilerin interfaceQuantiler- Parameters:
o- compatible quantiler to merge with this
-
ready
public void ready()Description copied from interface:QuantilerCall after all data has been accumulated and before quantiles are to be calculated. -
getValueAtQuantile
public double getValueAtQuantile(double quantile) Description copied from interface:QuantilerReturns the value at a given quantile.- Specified by:
getValueAtQuantilein interfaceQuantiler- Parameters:
quantile- value in the range 0..1- Returns:
- value at quantile, or NaN if no data
-