PpeOp extends Operator { static Double getMAD(double[] listDoubles) { Double median = getMedian(listDoubles); double[] listMAD = new double[5]; for (int i = 0; i < 5; i++) { if (listDoubles[i] != 0) { listMAD[i] = Math.abs(listDoubles[i] - median); } else { listMAD[i] = -1; } } Arrays.sort(listMAD); if (listMAD[1] == -1) { return listMAD[3]; } else if (listMAD[0] == -1) { return (listMAD[2] + listMAD[3]) / 2; } else { return listMAD[2]; } }  @Override void initialize(); @Override void computeTileStack(Map<Band, Tile> targetTiles, Rectangle targetRectangle, ProgressMonitor pm);  }
@Test public void testGetMAD() { double[] list = new double[]{1, 6, 3, 7, 11}; assertEquals(3, PpeOp.getMAD(list), 1e-10); double[] list2 = new double[]{0, 0, 3, 1, 11}; assertEquals(2, PpeOp.getMAD(list2), 1e-10); double[] list3 = new double[]{8, 0, 103, 20, 21}; assertEquals(6.5, PpeOp.getMAD(list3), 1e-10); }