Package adams.data.statistics
Class AbstractArrayStatistic<T extends Serializable>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.statistics.AbstractArrayStatistic<T>
-
- Type Parameters:
T
- the type of element in the arrays
- All Implemented Interfaces:
AdditionalInformationHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,ShallowCopySupporter<AbstractArrayStatistic>
,SizeOfHandler
,Serializable
- Direct Known Subclasses:
AbstractArrayDistance
,AbstractOptionalSampleArrayStatistic
,ArrayAndrewsCurves
,ArrayAngle
,ArrayBinning
,ArrayCorrelationCoefficient
,ArrayCovariance
,ArrayDifference
,ArrayHistogram
,ArrayKendallTheil
,ArrayLength
,ArrayLinearRegression
,ArrayMax
,ArrayMean
,ArrayMeanAbsoluteError
,ArrayMedian
,ArrayMin
,ArrayNormalize
,ArrayNormalizeRange
,ArrayPercentile
,ArrayRelativeAbsoluteError
,ArrayRootMeanSquaredError
,ArrayRootRelativeSquaredError
,ArrayRSquared
,ArraySum
,MultiArrayStatistic
public abstract class AbstractArrayStatistic<T extends Serializable> extends AbstractOptionHandler implements ShallowCopySupporter<AbstractArrayStatistic>, AdditionalInformationHandler
Ancestor for classes that calculate statistics from arrays.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractArrayStatistic.StatisticContainer<T extends Serializable>
The container for the generated statistic result.
-
Field Summary
Fields Modifier and Type Field Description protected List<T[]>
m_Data
for storing the arrays.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractArrayStatistic()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
add(T[] data)
Adds the array at the end.AbstractArrayStatistic.StatisticContainer
calculate()
Calculates the statistics and returns the result container.protected void
check()
Checks whether all pre-conditions are met.protected void
checkEqualLength()
Checks whether all the arrays have the same length.void
clear()
Removes all data currently stored.protected abstract AbstractArrayStatistic.StatisticContainer
doCalculate()
Generates the actual result.static AbstractArrayStatistic
forCommandLine(String cmdline)
Instantiates the statistic from the given commandline (i.e., classname and optional options).static AbstractArrayStatistic
forName(String classname, String[] options)
Instantiates the statistic with the given options.T[]
get(int index)
Returns the array at the specified location.String
getAdditionalInformation()
Returns the additional information.abstract int
getMax()
Returns the maximum number of arrays that need to be present.abstract int
getMin()
Returns the minimum number of arrays that need to be present.static String[]
getStatistics()
Returns a list with classnames of statistics.protected void
initialize()
Initializes the members.T[]
remove(int index)
Removes the array at the specified location.T[]
set(int index, T[] data)
Replaces the array at the specified location.AbstractArrayStatistic
shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.AbstractArrayStatistic
shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.int
size()
Returns the number of arrays stored.String
toString()
Returns a string representation of the current setup.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Data
protected List<T extends Serializable[]> m_Data
for storing the arrays.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractOptionHandler
-
clear
public void clear()
Removes all data currently stored.
-
size
public int size()
Returns the number of arrays stored.- Returns:
- the number of arrays
-
add
public void add(T[] data)
Adds the array at the end.- Parameters:
data
- the array to add
-
get
public T[] get(int index)
Returns the array at the specified location.- Parameters:
index
- the index of the array- Returns:
- the array
-
set
public T[] set(int index, T[] data)
Replaces the array at the specified location.- Parameters:
index
- the index of the arraydata
- the new array- Returns:
- the old array
-
remove
public T[] remove(int index)
Removes the array at the specified location.- Parameters:
index
- the index of the array- Returns:
- the deleted array
-
getMin
public abstract int getMin()
Returns the minimum number of arrays that need to be present. -1 for unbounded.- Returns:
- the minimum number, -1 for unbounded
-
getMax
public abstract int getMax()
Returns the maximum number of arrays that need to be present. -1 for unbounded.- Returns:
- the maximum number, -1 for unbounded
-
getAdditionalInformation
public String getAdditionalInformation()
Returns the additional information.- Specified by:
getAdditionalInformation
in interfaceAdditionalInformationHandler
- Returns:
- the additional information, null or 0-length string for no information
-
checkEqualLength
protected void checkEqualLength()
Checks whether all the arrays have the same length.
-
check
protected void check()
Checks whether all pre-conditions are met. Throws an IllegalStateException otherwise.
-
doCalculate
protected abstract AbstractArrayStatistic.StatisticContainer doCalculate()
Generates the actual result.- Returns:
- the generated result
-
calculate
public AbstractArrayStatistic.StatisticContainer calculate()
Calculates the statistics and returns the result container.- Returns:
- the generated result
-
toString
public String toString()
Returns a string representation of the current setup.- Overrides:
toString
in classAbstractOptionHandler
- Returns:
- the string representation
-
shallowCopy
public AbstractArrayStatistic shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceShallowCopySupporter<T extends Serializable>
- Returns:
- the shallow copy
-
shallowCopy
public AbstractArrayStatistic shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceShallowCopySupporter<T extends Serializable>
- Parameters:
expand
- whether to expand variables to their current values- Returns:
- the shallow copy
-
getStatistics
public static String[] getStatistics()
Returns a list with classnames of statistics.- Returns:
- the statistic classnames
-
forName
public static AbstractArrayStatistic forName(String classname, String[] options)
Instantiates the statistic with the given options.- Parameters:
classname
- the classname of the statistic to instantiateoptions
- the options for the statistic- Returns:
- the instantiated statistic or null if an error occurred
-
forCommandLine
public static AbstractArrayStatistic forCommandLine(String cmdline)
Instantiates the statistic from the given commandline (i.e., classname and optional options).- Parameters:
cmdline
- the classname (and optional options) of the statistic to instantiate- Returns:
- the instantiated statistic or null if an error occurred
-
-