Package microsim.statistics.functions
Class MovingAverageArrayFunction
java.lang.Object
microsim.statistics.functions.AbstractFunction
microsim.statistics.functions.AbstractArrayFunction
microsim.statistics.functions.MovingAverageArrayFunction
- All Implemented Interfaces:
EventListener,DoubleSource,UpdatableSource
This class computes the average of the last given number of values in an array taken from a data source. The mean
function return always a double value, so it implements the
DoubleSource interface and the standard
DoubleSource one.-
Nested Class Summary
Nested classes/interfaces inherited from interface microsim.statistics.DoubleSource
DoubleSource.Variables -
Field Summary
FieldsFields inherited from class microsim.statistics.functions.AbstractArrayFunction
dblSource, intSource, lngSource, type, TYPE_DBL, TYPE_INT, TYPE_LNGFields inherited from class microsim.statistics.functions.AbstractFunction
timeChecker -
Constructor Summary
ConstructorsConstructorDescriptionMovingAverageArrayFunction(@NonNull DoubleArraySource source, int windowSize) Create a count function on a double array source.MovingAverageArrayFunction(@NonNull IntArraySource source, int windowSize) Creates a count function on an integer array source.MovingAverageArrayFunction(@NonNull LongArraySource source, int windowSize) Creates a count function on a long array source. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(double @NonNull [] data) Applies the function to the given array of double values.voidapply(int @NonNull [] data) Applies the function to the given array of integer values.voidapply(long @NonNull [] data) Applies the function to the given array of long values.doublegetDoubleValue(@NonNull Enum<?> variableID) Returns the double value corresponding to the given variableIDMethods inherited from class microsim.statistics.functions.AbstractArrayFunction
applyFunctionMethods inherited from class microsim.statistics.functions.AbstractFunction
isCheckingTime, onEvent, setCheckingTime, updateSource
-
Field Details
-
mean
protected double mean -
window
protected int window
-
-
Constructor Details
-
MovingAverageArrayFunction
Creates a count function on an integer array source.- Parameters:
source- The data source.- Throws:
NullPointerException- whensourceisnull.IllegalArgumentException- whenwindowSizeis< 1.
-
MovingAverageArrayFunction
Creates a count function on a long array source.- Parameters:
source- The data source.- Throws:
NullPointerException- whensourceisnull.IllegalArgumentException- whenwindowSizeis< 1.
-
MovingAverageArrayFunction
Create a count function on a double array source.- Parameters:
source- The data source.- Throws:
NullPointerException- whensourceisnull.IllegalArgumentException- whenwindowSizeis< 1.
-
-
Method Details
-
apply
public void apply(double @NonNull [] data) Applies the function to the given array of double values.- Overrides:
applyin classAbstractArrayFunction- Parameters:
data- A source array of values.- Throws:
NullPointerException- whendataisnull.
-
apply
public void apply(int @NonNull [] data) Applies the function to the given array of integer values.- Overrides:
applyin classAbstractArrayFunction- Parameters:
data- A source array of values.- Throws:
NullPointerException- whendataisnull.
-
apply
public void apply(long @NonNull [] data) Applies the function to the given array of long values.- Overrides:
applyin classAbstractArrayFunction- Parameters:
data- A source array of values.- Throws:
NullPointerException- whendataisnull.
-
getDoubleValue
Returns the double value corresponding to the given variableID- Specified by:
getDoubleValuein interfaceDoubleSource- Parameters:
variableID- A unique identifier for a variable.- Returns:
- The current double value of the required variable.
- Throws:
NullPointerException- whendataisnull.
-