uk.ac.starlink.ttools.filter
Class QuantCalc

java.lang.Object
  extended by uk.ac.starlink.ttools.filter.QuantCalc

public abstract class QuantCalc
extends Object

Object for accumulating values in order to calculate quantiles.

Since:
2 May 2006
Author:
Mark Taylor

Field Summary
static double MAD_SCALE
          Value by which Median Absolute Deviation is scaled to estimate SD.
 
Constructor Summary
protected QuantCalc(Class clazz)
          Constructor.
 
Method Summary
abstract  void acceptDatum(Object obj)
          Submits a datum for accumulation.
static double calculateMedianAbsoluteDeviation(QuantCalc qcalc)
          Calculates the median absolute deviation of the statistics accumulated by a QuantCalc.
static QuantCalc createInstance(Class clazz, long nrow)
          Factory method to create a quantile accumulator for a given row count and value class.
abstract  Number getQuantile(double quant)
          Returns a quantile corresponding to a given point.
abstract  long getValueCount()
          Returns the number of non-blank values accumulated by this calculator.
abstract  Iterator<Number> getValueIterator()
          Returns an iterator over all the non-blank values accumulated by this calculator.
abstract  void ready()
          Call this method after all acceptDatum(java.lang.Object) calls have been made and before any call to getQuantile(double).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Constructor Detail

QuantCalc

protected QuantCalc(Class clazz)
Constructor.

Parameters:
clazz - class of data objects which will be submitted; must be assignable from Number class
Method Detail

acceptDatum

public abstract void acceptDatum(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 all acceptDatum(java.lang.Object) calls have been made and before any call to getQuantile(double).


getQuantile

public abstract 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 Iterator<Number> getValueIterator()
Returns an iterator over all the non-blank values accumulated by this calculator. If ready() has been called, they will be in ascending order. The number of values it iterates over will be equal to the result of getValueCount().

Returns:
value iterator

createInstance

public static QuantCalc createInstance(Class clazz,
                                       long nrow)
                                throws 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 unknown
clazz - class of data objects which will be submitted; must be assignable from Number.class.
Throws:
IOException

calculateMedianAbsoluteDeviation

public static double calculateMedianAbsoluteDeviation(QuantCalc qcalc)
                                               throws 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:
IOException


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.