Class StaticBin1D
- All Implemented Interfaces:
DoubleBufferConsumer, Serializable, Cloneable
- Direct Known Subclasses:
MightyStaticBin1D
The data streamed into a SimpleBin1D is not preserved!
As a consequence infinitely many elements can be added to this bin.
As a further consequence this bin cannot compute more than basic statistics.
It is also not rebinnable.
If these drawbacks matter, consider to use a DynamicBin1D,
which overcomes them at the expense of increased memory requirements.
This class is fully thread safe (all public methods are synchronized). Thus, you can have one or more threads adding to the bin as well as one or more threads reading and viewing the statistics of the bin while it is filled. For high performance, add data in large chunks (buffers) via method addAllOf rather than piecewise via method add.
Implementation: Incremental maintainance. Performance linear in the number of elements added.
- Version:
- 0.9, 03-Jul-99
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static double[]Function arguments used by method addAllOf(...) For memory tuning only.protected doubleprotected doubleprotected intThe number of elements consumed by incremental parameter maintainance.protected doubleprotected doubleFields inherited from class PersistentObject
serialVersionUID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(double element) Adds the specified element to the receiver.voidaddAllOfFromTo(DoubleArrayList list, int from, int to) Adds the part of the specified list between indexes from (inclusive) and to (inclusive) to the receiver.voidclear()Removes all elements from the receiver.protected voidResets the values of all measures.booleanReturns false.doublemax()Returns the maximum.doublemin()Returns the minimum.intsize()Returns the number of elements contained in the receiver.doublesum()Returns the sum of all elements, which is Sum( x[i] ).doubleReturns the sum of squares, which is Sum( x[i] * x[i] ).Methods inherited from class AbstractBin1D
addAllOf, buffered, compareWith, equals, mean, relError, rms, standardDeviation, standardError, toString, trimToSize, varianceMethods inherited from class PersistentObject
clone
-
Field Details
-
size
protected int sizeThe number of elements consumed by incremental parameter maintainance. -
min
protected double min -
max
protected double max -
sum
protected double sum -
sum_xx
protected double sum_xx -
arguments
protected static transient double[] argumentsFunction arguments used by method addAllOf(...) For memory tuning only. Avoids allocating a new array of arguments each time addAllOf(...) is called. Each bin does not need its own set of argument vars since they are declared as "static". addAllOf(...) of this class uses only 4 entries. Subclasses computing additional incremental statistics may need more arguments. So, to be on the safe side we allocate space for 20 args. Be sure you access this arguments only in synchronized blocks like synchronized (arguments) { do it } By the way, the whole fuss would be unnecessary if Java would know INOUT parameters (call by reference).
-
-
Constructor Details
-
StaticBin1D
public StaticBin1D()Constructs and returns an empty bin.
-
-
Method Details
-
add
public void add(double element) Adds the specified element to the receiver.- Specified by:
addin classAbstractBin1D- Parameters:
element- element to be appended.
-
addAllOfFromTo
Adds the part of the specified list between indexes from (inclusive) and to (inclusive) to the receiver.- Overrides:
addAllOfFromToin classAbstractBin1D- Parameters:
list- 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).- Throws:
IndexOutOfBoundsException- if list.size()>0 invalid input: '&'invalid input: '&' (from<0 || from>to || to>=list.size()).
-
clear
public void clear()Removes all elements from the receiver. The receiver will be empty after this call returns.- Specified by:
clearin classAbstractBin
-
clearAllMeasures
protected void clearAllMeasures()Resets the values of all measures. -
isRebinnable
public boolean isRebinnable()Returns false. Returns whether a client can obtain all elements added to the receiver. In other words, tells whether the receiver internally preserves all added elements. If the receiver is rebinnable, the elements can be obtained via elements() methods.- Specified by:
isRebinnablein classAbstractBin
-
max
-
min
-
size
public int size()Returns the number of elements contained in the receiver.- Specified by:
sizein classAbstractBin
-
sum
public double sum()Returns the sum of all elements, which is Sum( x[i] ).- Specified by:
sumin classAbstractBin1D
-
sumOfSquares
public double sumOfSquares()Returns the sum of squares, which is Sum( x[i] * x[i] ).- Specified by:
sumOfSquaresin classAbstractBin1D
-