Package microsim.statistics.functions
Class MeanVarianceArrayFunction
java.lang.Object
microsim.statistics.functions.AbstractFunction
microsim.statistics.functions.AbstractArrayFunction
microsim.statistics.functions.MeanVarianceArrayFunction
- All Implemented Interfaces:
EventListener
,DoubleSource
,UpdatableSource
This class computes the average and variance value of an array of values taken from a data source. The mean function
always returns double values, so it implements only the
In order to retrieve the mean pass the
DoubleSource
interface. In order to retrieve the mean pass the
MeanVarianceArrayFunction.Variables.MEAN
argument to the
getDoubleValue(Enum)
function, while for the variance the
MeanVarianceArrayFunction.Variables.VARIANCE
one.-
Nested Class Summary
-
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
ConstructorDescriptionMeanVarianceArrayFunction
(@NonNull DoubleArraySource source) Creates a mean function on a double array source.MeanVarianceArrayFunction
(@NonNull IntArraySource source) Creates a mean function on an integer array source.MeanVarianceArrayFunction
(@NonNull LongArraySource source) Creates a mean 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 -
variance
protected double variance
-
-
Constructor Details
-
MeanVarianceArrayFunction
Creates a mean function on an integer array source.- Parameters:
source
- The data source.- Throws:
NullPointerException
- whensource
isnull
.
-
MeanVarianceArrayFunction
Creates a mean function on a long array source.- Parameters:
source
- The data source.- Throws:
NullPointerException
- whensource
isnull
.
-
MeanVarianceArrayFunction
Creates a mean function on a double array source.- Parameters:
source
- The data source.- Throws:
NullPointerException
- whensource
isnull
.
-
-
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
.
-