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
Nested Classes -
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
ConstructorsConstructorDescriptionMeanVarianceArrayFunction(@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 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 -
variance
protected double variance
-
-
Constructor Details
-
MeanVarianceArrayFunction
Creates a mean function on an integer array source.- Parameters:
source- The data source.- Throws:
NullPointerException- whensourceisnull.
-
MeanVarianceArrayFunction
Creates a mean function on a long array source.- Parameters:
source- The data source.- Throws:
NullPointerException- whensourceisnull.
-
MeanVarianceArrayFunction
Creates a mean function on a double array source.- Parameters:
source- The data source.- Throws:
NullPointerException- whensourceisnull.
-
-
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.
-