@Test public void evaluate(){ List<Double> values = Arrays.asList(1d, 2d, 3d, 4d); assertEquals(2.5d, evaluate(values, 50)); }
public Double evaluate(Collection<?> values, int percentile){ if(percentile < 1 || percentile > 100){ throw new FunctionException(this, "Invalid \"percentile\" value " + percentile + ". Must be greater than 0 and equal or less than 100"); } DoubleVector doubleValues = new ComplexDoubleVector(values.size()); for(Object value : values){ Number number = (Number)TypeUtil.parseOrCast(DataType.DOUBLE, value); doubleValues.add(number.doubleValue()); } return doubleValues.doublePercentile(percentile); }
PercentileFunction extends BinaryFunction { public Double evaluate(Collection<?> values, int percentile){ if(percentile < 1 || percentile > 100){ throw new FunctionException(this, "Invalid \"percentile\" value " + percentile + ". Must be greater than 0 and equal or less than 100"); } DoubleVector doubleValues = new ComplexDoubleVector(values.size()); for(Object value : values){ Number number = (Number)TypeUtil.parseOrCast(DataType.DOUBLE, value); doubleValues.add(number.doubleValue()); } return doubleValues.doublePercentile(percentile); } }
PercentileFunction extends BinaryFunction { public Double evaluate(Collection<?> values, int percentile){ if(percentile < 1 || percentile > 100){ throw new FunctionException(this, "Invalid \"percentile\" value " + percentile + ". Must be greater than 0 and equal or less than 100"); } DoubleVector doubleValues = new ComplexDoubleVector(values.size()); for(Object value : values){ Number number = (Number)TypeUtil.parseOrCast(DataType.DOUBLE, value); doubleValues.add(number.doubleValue()); } return doubleValues.doublePercentile(percentile); } PercentileFunction();  PercentileFunction(String name); }
PercentileFunction extends BinaryFunction { public Double evaluate(Collection<?> values, int percentile){ if(percentile < 1 || percentile > 100){ throw new FunctionException(this, "Invalid \"percentile\" value " + percentile + ". Must be greater than 0 and equal or less than 100"); } DoubleVector doubleValues = new ComplexDoubleVector(values.size()); for(Object value : values){ Number number = (Number)TypeUtil.parseOrCast(DataType.DOUBLE, value); doubleValues.add(number.doubleValue()); } return doubleValues.doublePercentile(percentile); } PercentileFunction();  PercentileFunction(String name); Double evaluate(Collection<?> values, int percentile); @Override FieldValue evaluate(FieldValue first, FieldValue second); }
PercentileFunction extends BinaryFunction { public Double evaluate(Collection<?> values, int percentile){ if(percentile < 1 || percentile > 100){ throw new FunctionException(this, "Invalid \"percentile\" value " + percentile + ". Must be greater than 0 and equal or less than 100"); } DoubleVector doubleValues = new ComplexDoubleVector(values.size()); for(Object value : values){ Number number = (Number)TypeUtil.parseOrCast(DataType.DOUBLE, value); doubleValues.add(number.doubleValue()); } return doubleValues.doublePercentile(percentile); } PercentileFunction();  PercentileFunction(String name); Double evaluate(Collection<?> values, int percentile); @Override FieldValue evaluate(FieldValue first, FieldValue second);  }