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
Fields inherited from class microsim.statistics.functions.AbstractArrayFunction
dblSource, intSource, lngSource, type, TYPE_DBL, TYPE_INT, TYPE_LNG
Fields inherited from class microsim.statistics.functions.AbstractFunction
timeChecker
-
Constructor Summary
ConstructorDescriptionMovingAverageArrayFunction
(@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 TypeMethodDescriptionvoid
apply
(double @NonNull [] data) Applies the function to the given array of double values.void
apply
(int @NonNull [] data) Applies the function to the given array of integer values.void
apply
(long @NonNull [] data) Applies the function to the given array of long values.double
getDoubleValue
(@NonNull Enum<?> variableID) Returns the double value corresponding to the given variableIDMethods inherited from class microsim.statistics.functions.AbstractArrayFunction
applyFunction
Methods 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
- whensource
isnull
.IllegalArgumentException
- whenwindowSize
is< 1
.
-
MovingAverageArrayFunction
Creates a count function on a long array source.- Parameters:
source
- The data source.- Throws:
NullPointerException
- whensource
isnull
.IllegalArgumentException
- whenwindowSize
is< 1
.
-
MovingAverageArrayFunction
Create a count function on a double array source.- Parameters:
source
- The data source.- Throws:
NullPointerException
- whensource
isnull
.IllegalArgumentException
- whenwindowSize
is< 1
.
-
-
Method Details
-
apply
public void apply(double @NonNull [] data) Applies the function to the given array of double values.- Overrides:
apply
in classAbstractArrayFunction
- Parameters:
data
- A source array of values.- Throws:
NullPointerException
- whendata
isnull
.
-
apply
public void apply(int @NonNull [] data) Applies the function to the given array of integer values.- Overrides:
apply
in classAbstractArrayFunction
- Parameters:
data
- A source array of values.- Throws:
NullPointerException
- whendata
isnull
.
-
apply
public void apply(long @NonNull [] data) Applies the function to the given array of long values.- Overrides:
apply
in classAbstractArrayFunction
- Parameters:
data
- A source array of values.- Throws:
NullPointerException
- whendata
isnull
.
-
getDoubleValue
Returns the double value corresponding to the given variableID- Specified by:
getDoubleValue
in interfaceDoubleSource
- Parameters:
variableID
- A unique identifier for a variable.- Returns:
- The current double value of the required variable.
- Throws:
NullPointerException
- whendata
isnull
.
-