Package uk.ac.starlink.ttools.filter
Class QuantCalc
- java.lang.Object
-
- uk.ac.starlink.ttools.filter.QuantCalc
-
public abstract class QuantCalc extends java.lang.ObjectObject for accumulating values in order to calculate quantiles.- Since:
- 2 May 2006
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description static doubleMAD_SCALEValue by which Median Absolute Deviation is scaled to estimate SD.
-
Constructor Summary
Constructors Modifier Constructor Description protectedQuantCalc(java.lang.Class<?> clazz)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidacceptDatum(java.lang.Object obj)Submits a datum for accumulation.static doublecalculateMedianAbsoluteDeviation(QuantCalc qcalc)Calculates the median absolute deviation of the statistics accumulated by a QuantCalc.static QuantCalccreateInstance(java.lang.Class<? extends java.lang.Number> clazz, long nrow)Factory method to create a quantile accumulator for a given row count and value class.abstract java.lang.NumbergetQuantile(double quant)Returns a quantile corresponding to a given point.abstract longgetValueCount()Returns the number of non-blank values accumulated by this calculator.abstract java.util.Iterator<java.lang.Number>getValueIterator()Returns an iterator over all the non-blank values accumulated by this calculator.abstract voidready()Call this method after allacceptDatum(java.lang.Object)calls have been made and before any call togetQuantile(double).
-
-
-
Field Detail
-
MAD_SCALE
public static final double MAD_SCALE
Value by which Median Absolute Deviation is scaled to estimate SD.- See Also:
- Constant Field Values
-
-
Method Detail
-
acceptDatum
public abstract void acceptDatum(java.lang.Object obj)
Submits a datum for accumulation.- Parameters:
obj- data object - must be instance of numeric class suitable for this accumulator
-
ready
public abstract void ready()
Call this method after allacceptDatum(java.lang.Object)calls have been made and before any call togetQuantile(double).
-
getQuantile
public abstract java.lang.Number getQuantile(double quant)
Returns a quantile corresponding to a given point.- Parameters:
quant- quant value between 0 and 1, for instance 0.5 indicates median
-
getValueCount
public abstract long getValueCount()
Returns the number of non-blank values accumulated by this calculator.- Returns:
- value count
-
getValueIterator
public abstract java.util.Iterator<java.lang.Number> getValueIterator()
Returns an iterator over all the non-blank values accumulated by this calculator. Ifready()has been called, they will be in ascending order. The number of values it iterates over will be equal to the result ofgetValueCount().- Returns:
- value iterator
-
createInstance
public static QuantCalc createInstance(java.lang.Class<? extends java.lang.Number> clazz, long nrow) throws java.io.IOException
Factory method to create a quantile accumulator for a given row count and value class.- Parameters:
nrow- row count; may be -1 to indicate that the row count is unknownclazz- class of data objects which will be submitted; must be assignable from Number.class.- Throws:
java.io.IOException
-
calculateMedianAbsoluteDeviation
public static double calculateMedianAbsoluteDeviation(QuantCalc qcalc) throws java.io.IOException
Calculates the median absolute deviation of the statistics accumulated by a QuantCalc.- Parameters:
qcalc- calculator in ready state- Returns:
- sum(abs(x_i - median))
- Throws:
java.io.IOException
-
-