mirror of https://github.com/apache/poi.git
small refactor
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901275 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bedf2a4e6d
commit
3d57a45f65
|
@ -30,13 +30,12 @@ import java.util.ArrayList;
|
|||
* Gets the standard deviation value of a column in an area with given conditions.
|
||||
*/
|
||||
public final class DStdev implements IDStarAlgorithm {
|
||||
private final ArrayList<Double> values = new ArrayList<>();
|
||||
private final ArrayList<NumericValueEval> values = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public boolean processMatch(ValueEval eval) {
|
||||
if (eval instanceof NumericValueEval) {
|
||||
final double val = ((NumericValueEval)eval).getNumberValue();
|
||||
values.add(val);
|
||||
values.add((NumericValueEval) eval);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -45,8 +44,8 @@ public final class DStdev implements IDStarAlgorithm {
|
|||
public ValueEval getResult() {
|
||||
final double[] array = new double[values.size()];
|
||||
int pos = 0;
|
||||
for (Double d : values) {
|
||||
array[pos++] = d;
|
||||
for (NumericValueEval d : values) {
|
||||
array[pos++] = d.getNumberValue();
|
||||
}
|
||||
final double stdev = StatsLib.stdev(array);
|
||||
return new NumberEval(new BigDecimal(NumberToTextConverter.toText(stdev)).doubleValue());
|
||||
|
|
|
@ -30,13 +30,12 @@ import java.util.ArrayList;
|
|||
* Gets the variance value of a column in an area with given conditions.
|
||||
*/
|
||||
public final class DVar implements IDStarAlgorithm {
|
||||
private final ArrayList<Double> values = new ArrayList<>();
|
||||
private final ArrayList<NumericValueEval> values = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public boolean processMatch(ValueEval eval) {
|
||||
if (eval instanceof NumericValueEval) {
|
||||
final double val = ((NumericValueEval)eval).getNumberValue();
|
||||
values.add(val);
|
||||
values.add((NumericValueEval) eval);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -45,8 +44,8 @@ public final class DVar implements IDStarAlgorithm {
|
|||
public ValueEval getResult() {
|
||||
final double[] array = new double[values.size()];
|
||||
int pos = 0;
|
||||
for (Double d : values) {
|
||||
array[pos++] = d;
|
||||
for (NumericValueEval d : values) {
|
||||
array[pos++] = d.getNumberValue();
|
||||
}
|
||||
final double var = StatsLib.var(array);
|
||||
return new NumberEval(new BigDecimal(NumberToTextConverter.toText(var)).doubleValue());
|
||||
|
|
Loading…
Reference in New Issue