Holger's
Java API

com.antelmann.math
Class DataPoint

java.lang.Object
  extended by com.antelmann.math.DataPoint
All Implemented Interfaces:
Addable<DataPoint>, DetailedString, Serializable

public class DataPoint
extends Object
implements Serializable, Addable<DataPoint>, DetailedString

represents an immutable data point holding aggregated information for a specific data vector based on BigDecimal

See Also:
DataMatrix, TimeDataGrid, Serialized Form

Nested Class Summary
static class DataPoint.ValueType
          defines what value of a DataPoint is of interest
 
Field Summary
static Comparator<DataPoint> COUNT_COMPARATOR
          allows to sort DataPoints by their count (ascending)
static Comparator<DataPoint> SUM_COMPARATOR
          allows to sort DataPoints by their sum (ascending)
 
Constructor Summary
DataPoint()
          initializes the data point with a count of 0; only use an instance constructed like this if you added some data later!
DataPoint(BigDecimal n)
           
DataPoint(BigDecimal sum, BigDecimal min, BigDecimal max)
           
DataPoint(int count, BigDecimal sum, BigDecimal min, BigDecimal max, BigDecimal squareSum)
           
DataPoint(Number n)
           
DataPoint(Number sum, Number min, Number max)
           
DataPoint(Number count, Number sum, Number min, Number max, Number squareSum)
           
 
Method Summary
 DataPoint add(BigDecimal number)
           
 DataPoint add(DataPoint dp)
          the returned DataPoint is an aggregation of this instance and the given one
 DataPoint add(Number number)
           
static
<T,P> HashMap<P,DataPoint>
aggregate(Map<T,DataPoint> data, PatternExtractor<? super T,? extends P> pe)
           
static
<T> HashMap<T,Double>
convertToDoubleMap(Map<T,DataPoint> data, DataPoint.ValueType type)
           
static
<T> HashMap<T,BigDecimal>
convertToValueMap(Map<T,DataPoint> data, DataPoint.ValueType type)
           
 boolean equals(Object obj)
           
 double getAverage()
           
 long getCount()
           
 BigDecimal getMax()
           
 BigDecimal getMin()
           
 double getSampleStandardDeviation()
          only applicable for a count greater than 1
 BigDecimal getSquareSum()
           
 double getStandardDeviation()
           
 BigDecimal getSum()
           
 BigDecimal getValue(DataPoint.ValueType type)
           
 int hashCode()
           
 String toDetailedString()
          provides full details of this instance in a String.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SUM_COMPARATOR

public static final Comparator<DataPoint> SUM_COMPARATOR
allows to sort DataPoints by their sum (ascending)

See Also:
getSum()

COUNT_COMPARATOR

public static final Comparator<DataPoint> COUNT_COMPARATOR
allows to sort DataPoints by their count (ascending)

See Also:
getCount()
Constructor Detail

DataPoint

@Warning(value={"The instance constructed like this itself is pointless unless used to add another instance to avoid null pointer!","All methods that divide by the count will throw an exception."})
public DataPoint()
initializes the data point with a count of 0; only use an instance constructed like this if you added some data later!


DataPoint

public DataPoint(Number n)

DataPoint

public DataPoint(BigDecimal n)

DataPoint

public DataPoint(Number sum,
                 Number min,
                 Number max)

DataPoint

public DataPoint(BigDecimal sum,
                 BigDecimal min,
                 BigDecimal max)

DataPoint

public DataPoint(Number count,
                 Number sum,
                 Number min,
                 Number max,
                 Number squareSum)

DataPoint

public DataPoint(int count,
                 BigDecimal sum,
                 BigDecimal min,
                 BigDecimal max,
                 BigDecimal squareSum)
Method Detail

getValue

public BigDecimal getValue(DataPoint.ValueType type)

add

public DataPoint add(DataPoint dp)
the returned DataPoint is an aggregation of this instance and the given one

Specified by:
add in interface Addable<DataPoint>

add

public DataPoint add(Number number)

add

public DataPoint add(BigDecimal number)

getStandardDeviation

@Todo(value="implement this method so that it wouldn\'t suffer accuracy loss on hight square sums")
@Warning(value="the current implementation is inappropriate for high values due to rounding issues")
public double getStandardDeviation()

getSampleStandardDeviation

@Todo(value="implement this method so that it wouldn\'t suffer accuracy loss on hight square sums")
@Warning(value="the current implementation is inappropriate for high values due to rounding issues")
public double getSampleStandardDeviation()
only applicable for a count greater than 1


getAverage

public double getAverage()

getCount

public final long getCount()

getSum

public final BigDecimal getSum()

getMin

public final BigDecimal getMin()

getMax

public final BigDecimal getMax()

getSquareSum

public final BigDecimal getSquareSum()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

toDetailedString

public String toDetailedString()
Description copied from interface: DetailedString
provides full details of this instance in a String. In case the String contains multiple lines, it is recommended to use '\n' rather than the platform specific line-break for better compatibility.

Specified by:
toDetailedString in interface DetailedString
Returns:
a (potentially multi-line) String providing full details on this object instance

aggregate

public static <T,P> HashMap<P,DataPoint> aggregate(Map<T,DataPoint> data,
                                                   PatternExtractor<? super T,? extends P> pe)

convertToDoubleMap

public static <T> HashMap<T,Double> convertToDoubleMap(Map<T,DataPoint> data,
                                                       DataPoint.ValueType type)

convertToValueMap

public static <T> HashMap<T,BigDecimal> convertToValueMap(Map<T,DataPoint> data,
                                                          DataPoint.ValueType type)


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads