T
- The type of numbers measuredpublic abstract class NumberSeriesImpl<T extends Number>extends SeriesImpl<T>
Modifier and Type | Field and Description |
---|---|
protected long | count |
Constructor and Description |
---|
NumberSeriesImpl(Comparator<T> comparator, Class<T> clazz) |
Modifier and Type | Method and Description |
---|---|
protected abstract T | calcNativeMedian(T a, T b) Abstract method which must be implemented by sub-classes. |
static <T> SeriesProvider<T> | createIfKnown(Class<T> clazz) Creates a SeriesProvider for a built-in series type. |
protected Formatter | formatMetrics(Formatter f) Formats metrics for this class using the supplied formatter. |
Map<Long,T> | getAll() Returns all measured values as a map from the tick to the value. |
Double | getAverage() Returns an average (arithmetic mean) of all measured values. |
Map<Long,Double> | getAveraged(long classWidth) Returns an averaged version of all values. |
long | getCount() Returns the number of measured values. |
Double | getDoubleMedian() Returns the median of all measured values. |
static Collection<Class<?>> | getKnownSeriesClasses() Returns a list of all known series classes. |
T | getMax() Returns the maximum value of all measured values. |
T | getMin() Returns the minimum value of all measured values. |
T | getNativeMedian() Returns the median of all measured values. |
T[] | getNativeMedians() Returns the median candidates of all measured values. |
Double | getStandardDeviation() Returns the standard deviation of all measured values. |
Class<T> | getValueClass() Returns the runtime class type for T |
boolean | hasSingleMedian() Determines whether the series has one median (because it has an odd number of values, or because it is even and two median candidates are equal). |
void | initialize(Simulation sim) Initializes the series provider. |
void | measure(T value) Adds a measured value to the series. |
protected T | medianA() |
protected T | medianB() |
toString
public NumberSeriesImpl(Comparator<T> comparator, Class<T> clazz)
public Class<T> getValueClass()
SeriesProvider
T
T
public void initialize(Simulation sim)
SeriesProvider
Series
or SeriesResult
.sim
- The simulation this series is to be performed atpublic Map<Long,T> getAll()
SeriesResult
public Map<Long,Double> getAveraged(long classWidth)
SeriesResult
classWidth
. The returned map contains all averaged results as a map from the tick (the beginning, "left border" of the class) to the average value.classWidth
- the width in ticks for the classesprotected abstract T calcNativeMedian(T a, T b)
a
- the first (left) median candidateb
- the second (right) median candidatepublic void measure(T value)
Series
value
- the value to addpublic Double getAverage()
SeriesResult
public boolean hasSingleMedian()
SeriesResult
protected T medianA()
protected T medianB()
public Double getDoubleMedian()
SeriesResult
Double
, even if the measured values are integer and one median is present. For a more exact version, see SeriesResult.getNativeMedian()
. If there are two median values (because the number of measurements is even), the arithmetic mean of the two values is returned.public Double getStandardDeviation()
SeriesResult
public long getCount()
SeriesResult
public T getMin()
SeriesResult
public T getMax()
SeriesResult
public T[] getNativeMedians()
SeriesResult
public T getNativeMedian()
SeriesResult
SeriesResult.getDoubleMedian()
, this method returns an exact median if there is one median. If there are two median values, the returned value depends on the implemented measurement series, but will be performed in a mean-like way (possible rounded towards some integer value).public static Collection<Class<?>> getKnownSeriesClasses()
public static <T> SeriesProvider<T> createIfKnown(Class<T> clazz)
SeriesProvider
for a built-in series type. Returns null
if the provided type is not built-in.T
- the (static) type of series to createclazz
- the (runtime) type of series to createprotected Formatter formatMetrics(Formatter f)
SeriesImpl
formatMetrics
in class SeriesImpl<T extends Number>
f
- the formatter to useformatter
)Copyright © 2015. All rights reserved.