Class QuantCalc


  • public abstract class QuantCalc
    extends java.lang.Object
    Object for accumulating values in order to calculate quantiles.
    Since:
    2 May 2006
    Author:
    Mark Taylor
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double MAD_SCALE
      Value by which Median Absolute Deviation is scaled to estimate SD.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected QuantCalc​(java.lang.Class clazz)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void acceptDatum​(java.lang.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​(java.lang.Class clazz, long nrow)
      Factory method to create a quantile accumulator for a given row count and value class.
      abstract java.lang.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 java.util.Iterator<java.lang.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​(java.lang.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​(java.lang.Object obj)
        Submits a datum for accumulation.
        Parameters:
        obj - data object - must be instance of numeric class suitable for this accumulator
      • 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. 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​(java.lang.Class 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 unknown
        clazz - 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