List of usage examples for org.apache.commons.math3.stat.descriptive StorelessUnivariateStatistic getResult
double getResult();
From source file:org.jpmml.evaluator.functions.AggregateFunction.java
@Override public FieldValue evaluate(List<FieldValue> arguments) { StorelessUnivariateStatistic statistic = createStatistic(); DataType dataType = null;// ww w . ja va 2 s.co m // "Missing values in the input to an aggregate function are simply ignored" Iterable<FieldValue> values = Iterables.filter(arguments, Predicates.notNull()); for (FieldValue value : values) { statistic.increment((value.asNumber()).doubleValue()); if (dataType != null) { dataType = TypeUtil.getResultDataType(dataType, value.getDataType()); } else { dataType = value.getDataType(); } } if (statistic.getN() == 0) { throw new InvalidResultException(null); } Object result = cast(getResultType(dataType), statistic.getResult()); return FieldValueUtil.create(result); }