Package cern.jet.stat.quantile
Class DoubleQuantileEstimator
- java.lang.Object
-
- cern.colt.PersistentObject
-
- cern.jet.stat.quantile.DoubleQuantileEstimator
-
- All Implemented Interfaces:
DoubleQuantileFinder,java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
KnownDoubleQuantileEstimator,UnknownDoubleQuantileEstimator
abstract class DoubleQuantileEstimator extends PersistentObject implements DoubleQuantileFinder
The abstract base class for approximate quantile finders computing quantiles over a sequence of double elements.
-
-
Field Summary
Fields Modifier and Type Field Description protected DoubleBufferSetbufferSetprotected DoubleBuffercurrentBufferToFillprotected inttotalElementsFilled-
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDoubleQuantileEstimator()Makes this class non instantiable, but still let's others inherit from it.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidadd(double value)Adds a value to the receiver.voidaddAllOf(DoubleArrayList values)Adds all values of the specified list to the receiver.voidaddAllOfFromTo(DoubleArrayList values, int from, int to)Adds the part of the specified list between indexes from (inclusive) and to (inclusive) to the receiver.protected DoubleBuffer[]buffersToCollapse()Not yet commented.voidclear()Removes all elements from the receiver.java.lang.Objectclone()Returns a deep copy of the receiver.protected voidcollapse()Not yet commented.booleancontains(double element)Returns whether the specified element is contained in the receiver.booleanforEach(DoubleProcedure procedure)Applies a procedure to each element of the receiver, if any.longmemory()Returns the number of elements currently needed to store all contained elements.protected abstract voidnewBuffer()Not yet commented.doublephi(double element)Returns how many percent of the elements contained in the receiver are <= element.protected abstract voidpostCollapse(DoubleBuffer[] toCollapse)Not yet commented.protected DoubleArrayListpreProcessPhis(DoubleArrayList phis)Default implementation does nothing.DoubleArrayListquantileElements(DoubleArrayList phis)Computes the specified quantile elements over the values previously added.protected abstract booleansampleNextElement()Not yet commented.protected voidsetUp(int b, int k)Initializes the receiverlongsize()Returns the number of elements currently contained in the receiver (identical to the number of values added so far).java.lang.StringtoString()Returns a String representation of the receiver.longtotalMemory()Returns the number of elements currently needed to store all contained elements.
-
-
-
Field Detail
-
bufferSet
protected DoubleBufferSet bufferSet
-
currentBufferToFill
protected DoubleBuffer currentBufferToFill
-
totalElementsFilled
protected int totalElementsFilled
-
-
Method Detail
-
add
public void add(double value)
Adds a value to the receiver.- Specified by:
addin interfaceDoubleQuantileFinder- Parameters:
value- the value to add.
-
addAllOf
public void addAllOf(DoubleArrayList values)
Adds all values of the specified list to the receiver.- Specified by:
addAllOfin interfaceDoubleQuantileFinder- Parameters:
values- the list of which all values shall be added.
-
addAllOfFromTo
public void addAllOfFromTo(DoubleArrayList values, int from, int to)
Adds the part of the specified list between indexes from (inclusive) and to (inclusive) to the receiver.- Specified by:
addAllOfFromToin interfaceDoubleQuantileFinder- Parameters:
values- the list of which elements shall be added.from- the index of the first element to be added (inclusive).to- the index of the last element to be added (inclusive).
-
buffersToCollapse
protected DoubleBuffer[] buffersToCollapse()
Not yet commented.
-
clear
public void clear()
Removes all elements from the receiver. The receiver will be empty after this call returns, and its memory requirements will be close to zero.- Specified by:
clearin interfaceDoubleQuantileFinder
-
clone
public java.lang.Object clone()
Returns a deep copy of the receiver.- Specified by:
clonein interfaceDoubleQuantileFinder- Overrides:
clonein classPersistentObject- Returns:
- a deep copy of the receiver.
-
collapse
protected void collapse()
Not yet commented.
-
contains
public boolean contains(double element)
Returns whether the specified element is contained in the receiver.
-
forEach
public boolean forEach(DoubleProcedure procedure)
Applies a procedure to each element of the receiver, if any. Iterates over the receiver in no particular order.- Specified by:
forEachin interfaceDoubleQuantileFinder- Parameters:
procedure- the procedure to be applied. Stops iteration if the procedure returns false, otherwise continues.- Returns:
- false if the procedure stopped before all elements where iterated over, true otherwise.
-
memory
public long memory()
Returns the number of elements currently needed to store all contained elements. This number usually differs from the results of method size(), according to the underlying datastructure.- Specified by:
memoryin interfaceDoubleQuantileFinder
-
newBuffer
protected abstract void newBuffer()
Not yet commented.
-
phi
public double phi(double element)
Returns how many percent of the elements contained in the receiver are <= element. Does linear interpolation if the element is not contained but lies in between two contained elements.- Specified by:
phiin interfaceDoubleQuantileFinder- Parameters:
the- element to search for.- Returns:
- the percentage p of elements <= element (0.0 <= p <=1.0).
-
postCollapse
protected abstract void postCollapse(DoubleBuffer[] toCollapse)
Not yet commented.
-
preProcessPhis
protected DoubleArrayList preProcessPhis(DoubleArrayList phis)
Default implementation does nothing.
-
quantileElements
public DoubleArrayList quantileElements(DoubleArrayList phis)
Computes the specified quantile elements over the values previously added.- Specified by:
quantileElementsin interfaceDoubleQuantileFinder- Parameters:
phis- the quantiles for which elements are to be computed. Each phi must be in the interval [0.0,1.0]. phis must be sorted ascending.- Returns:
- the approximate quantile elements.
-
sampleNextElement
protected abstract boolean sampleNextElement()
Not yet commented.
-
setUp
protected void setUp(int b, int k)Initializes the receiver
-
size
public long size()
Returns the number of elements currently contained in the receiver (identical to the number of values added so far).- Specified by:
sizein interfaceDoubleQuantileFinder
-
toString
public java.lang.String toString()
Returns a String representation of the receiver.- Overrides:
toStringin classjava.lang.Object
-
totalMemory
public long totalMemory()
Returns the number of elements currently needed to store all contained elements. This number usually differs from the results of method size(), according to the underlying datastructure.- Specified by:
totalMemoryin interfaceDoubleQuantileFinder
-
-