public class Average extends ArrayFunctionBase implements RealUnaryFunction
Since Jep 3.4 this function will flatten its arguments so avg([1,[2,3]])
will be 2.
ArrayFunctionBase.ZeroLengthErrorBehaviour
Modifier and Type | Field and Description |
---|---|
protected Add |
add
Function used to add pairs of elements
|
protected Divide |
div
Function used to divide sum of elements by the number of elements
|
curNumberOfParameters, name, NaN, numberOfParameters
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
average(java.util.List<java.lang.Object> vals)
Returns the average of a set of values.
|
protected java.lang.Object |
calc(java.util.List<java.lang.Object> v)
Called by the run method, default is to call
average(List) but subclasses can override. |
double |
evaluate(double val)
Just returns its argument.
|
addToArray, checkNumberOfParameters, getZeroLengthErrorBehaviour, run, setZeroLengthErrorBehaviour, throwAtLeastOneExcep
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
protected Add add
protected Divide div
protected java.lang.Object calc(java.util.List<java.lang.Object> v) throws EvaluationException
average(List)
but subclasses can override.calc
in class ArrayFunctionBase
v
- a list of objects to calculate the average of.EvaluationException
- if the calculation cannot be performedpublic java.lang.Object average(java.util.List<java.lang.Object> vals) throws EvaluationException
vals
- Values to be averagedEvaluationException
- if the calculation cannot be performedpublic double evaluate(double val)
evaluate
in interface RealUnaryFunction
Copyright © 2018 Singular Systems http://www.singularsys.com/jep