add VARPA and STDEVPA functions

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901300 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-05-26 22:47:07 +00:00
parent c84eee1b8e
commit 86664455a8
2 changed files with 31 additions and 3 deletions

View File

@ -336,8 +336,8 @@ public final class FunctionEval {
retval[361] = AggregateFunction.AVERAGEA;
retval[362] = MinaMaxa.MAXA;
retval[363] = MinaMaxa.MINA;
// 364: STDEVPA
// 365: VARPA
retval[364] = AggregateFunction.STDEVPA;
retval[365] = AggregateFunction.VARPA;
retval[366] = AggregateFunction.STDEVA;
retval[367] = AggregateFunction.VARA;

View File

@ -265,6 +265,20 @@ public abstract class AggregateFunction extends MultiOperandNumericFunction {
return StatsLib.stdev(values);
}
};
public static final Function STDEVPA = new AggregateFunction() {
@Override
protected boolean handleLogicalValues() {
return true;
}
@Override
protected double evaluate(double[] values) throws EvaluationException {
if (values.length < 1) {
throw new EvaluationException(ErrorEval.DIV_ZERO);
}
return StatsLib.stdevp(values);
}
};
public static final Function SUM = new AggregateFunction() {
protected double evaluate(double[] values) {
return MathX.sum(values);
@ -305,6 +319,20 @@ public abstract class AggregateFunction extends MultiOperandNumericFunction {
return StatsLib.var(values);
}
};
public static final Function VARPA = new AggregateFunction() {
@Override
protected boolean handleLogicalValues() {
return true;
}
@Override
protected double evaluate(double[] values) throws EvaluationException {
if (values.length < 1) {
throw new EvaluationException(ErrorEval.DIV_ZERO);
}
return StatsLib.varp(values);
}
};
public static final Function GEOMEAN = new Geomean();
private static class Product extends AggregateFunction {