org.jaitools.numeric
Class ExactMedianProcessor

java.lang.Object
  extended by org.jaitools.numeric.AbstractProcessor
      extended by org.jaitools.numeric.ExactMedianProcessor
All Implemented Interfaces:
Processor

public class ExactMedianProcessor
extends AbstractProcessor

Processor for the exact median Statistic.MEDIAN.

Note: this processor stores sll accepted sample values in memory in order to calculate the exact median. For very large data streams Statistic.APPROX_MEDIAN might be preferred.

Since:
1.0
Version:
$Id$
Author:
Michael Bedward
See Also:
Statistic, StreamingSampleStats

Field Summary
 
Fields inherited from class org.jaitools.numeric.AbstractProcessor
numAccepted, numNaN, numNoData, numOffered
 
Constructor Summary
ExactMedianProcessor()
           
 
Method Summary
 Double get(Statistic stat)
          Gets the value of the statistic calculated by this processor.
 Collection<Statistic> getSupported()
          Gets the Statistics supported by this processor.
 void offer(Double sample)
          Offers a sample value to the processor.
protected  boolean update(Double sample)
          Processes a sample value.
 
Methods inherited from class org.jaitools.numeric.AbstractProcessor
addNoDataRange, addNoDataValue, addRange, addRange, get, getNoDataRanges, getNumAccepted, getNumNaN, getNumNoData, getNumOffered, getRanges, getRangesType, isAccepted, setRangesType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExactMedianProcessor

public ExactMedianProcessor()
Method Detail

getSupported

public Collection<Statistic> getSupported()
Gets the Statistics supported by this processor.

Returns:
supported Statistics

offer

public final void offer(Double sample)
Offers a sample value to the processor. The maximum number of sample values than can be stored is Integer.MAX_VALUE (available memory permitting). Once this limit is reached, subsequent values will be rejected and a warning message will be logged.

Specified by:
offer in interface Processor
Overrides:
offer in class AbstractProcessor
Parameters:
sample - the sample value

update

protected boolean update(Double sample)
Processes a sample value..

Specified by:
update in class AbstractProcessor
Parameters:
sample - the sample value
Returns:
true if the sample is accepted; false otherwise

get

public Double get(Statistic stat)
Gets the value of the statistic calculated by this processor..

Parameters:
stat - the specified statistic
Returns:
the value of the statistic if it has been calculated or Double.NaN otherwise


Copyright © 2009-2013. All Rights Reserved.