EdmxEstimator { public static EdmxEstimate estimate(double[] data, int delta, int numPerms) { val scaledData = DataUtil.unitScale(data); val breakout = estimateSimpleBreakout(scaledData, delta); val energyDistance = breakout.getEnergyDistance(); val pValue = estimatePValue(scaledData, delta, numPerms, energyDistance); return new EdmxEstimate() .setLocation(breakout.location) .setEnergyDistance(breakout.energyDistance) .setPreBreakoutMedian(breakout.preBreakoutMedian) .setPostBreakoutMedian(breakout.postBreakoutMedian) .setPValue(pValue); }  static EdmxEstimate estimate(double[] data, int delta, int numPerms);  }
@Test public void testEdmx_range0() { val data = new double[100]; Arrays.fill(data, 1.0); val estBreakout = EdmxEstimator.estimate(data, 24, 0); assertEquals(-1, estBreakout.getLocation()); }
@Test public void testEdmx_noBreakout() { val data = new double[100]; for (int i = 0; i < data.length; i++) { data[i] = i % 2 == 0 ? 1.0 : 1.2; } val result1 = EdmxEstimator.estimate(data, 5, 0); log.trace("result1={}", result1); assertEquals(49, result1.getLocation()); assertEquals(24.99, result1.getEnergyDistance(), TOLERANCE); val result2 = EdmxEstimator.estimate(data, 5, 20); log.trace("result2={}", result2); assertEquals(49, result2.getLocation()); assertEquals(24.99, result2.getEnergyDistance(), TOLERANCE); }
@Test public void testEdmx_shortSeries_smallBreakout_noPerms() { val data = new double[10]; for (int i = 0; i < data.length; i++) { data[i] = random.nextGaussian() + (i >= 8 ? 3.0 : 0.0); } val result = EdmxEstimator.estimate(data, 2, 0); assertEquals(8, result.getLocation()); assertEquals(0.455, result.getEnergyDistance(), TOLERANCE); }
@Test public void testEdmx_shortSeries_largeBreakout_noPerms() { val data = new double[10]; for (int i = 0; i < data.length; i++) { data[i] = random.nextGaussian() + (i >= 8 ? 100.0 : 0.0); } val result = EdmxEstimator.estimate(data, 2, 0); assertEquals(7, result.getLocation()); assertEquals(1.986, result.getEnergyDistance(), TOLERANCE); }
@Test public void testEdmx_longSeries_smallBreakout_noPerms() { val data = new double[100]; for (int i = 0; i < data.length; i++) { data[i] = random.nextGaussian() + (i >= 80 ? 3.0 : 0.0); } val result = EdmxEstimator.estimate(data, 10, 0); assertEquals(75, result.getLocation()); assertEquals(2.569, result.getEnergyDistance(), TOLERANCE); }