StellarStatisticsFunctions { private static StatisticsProvider statsInit(List<Object> args) { int windowSize = 0; if(args.size() > 0 && args.get(0) instanceof Number) { windowSize = convert(args.get(0), Integer.class); } if(windowSize > 0) { return new WindowedStatisticsProvider(windowSize); } return new OnlineStatisticsProvider(); }    }
@Test public void testPercentileNoWindow() { statsInit(0); final double percentile = 0.9; Object actual = run(format("STATS_PERCENTILE(stats, %f)", percentile), variables); assertEquals(stats.getPercentile(percentile), (Double) actual, 1); }
@Test public void testPercentileWithWindow() { statsInit(100); final double percentile = 0.9; Object actual = run(format("STATS_PERCENTILE(stats, %f)", percentile), variables); assertEquals(stats.getPercentile(percentile), (Double) actual, 0.1); }