@@ -0,0 +1,1761 @@
+/*-%0A * Copyright 2016 Diamond Light Source Ltd.%0A *%0A * All rights reserved. This program and the accompanying materials%0A * are made available under the terms of the Eclipse Public License v1.0%0A * which accompanies this distribution, and is available at%0A * http://www.eclipse.org/legal/epl-v10.html%0A */%0A%0Apackage org.eclipse.dawnsci.analysis.dataset.impl;%0A%0Apublic class Outliers %7B%0A%0A%09private final static double MADSCALEFACTOR = 1.4826;%0A%09private final static double SNSCALEFACTOR = 1.1926;%0A%09%0A%09public static double%5B%5D medianAbsoluteDeviation(Dataset data) %7B%0A%09%09%0A%09%09double median = (Double)Stats.median(data);%0A%09%09data = Maths.subtract(data, median);%0A%09%09data = Maths.abs(data);%0A%09%09double median2 = (Double)Stats.median(data);%0A%09%09double mad = MADSCALEFACTOR * median2;%0A%09%09%0A%09%09return new double%5B%5D%7Bmad, median%7D;%0A%09%7D%0A%09%0A%09public static double snNaive(Dataset data) %7B%0A%09%09%0A%09%09Dataset medAbs = DatasetFactory.zeros(data);%0A%09%09Dataset dif = DatasetFactory.zeros(data);%0A%09%09%0A%09%09IndexIterator it = data.getIterator();%0A%09%09int count = 0;%0A%09%09while (it.hasNext()) %7B%0A%09%09%09double val = data.getElementDoubleAbs(it.index);%0A%09%09%09Maths.subtract(data, val, dif);%0A%09%09%09Maths.abs(dif,dif);%0A%09%09%09//Lower median - Math.floor((n/2)+1) of sorted%0A%09%09%09dif.sort(null);%0A%09%09%09medAbs.setObjectAbs(count++, dif.getElementDoubleAbs((int)Math.floor((dif.getSize()/2)+1)));%0A%09%09%7D%0A%09%09%0A%09%09%0A%09%09//Higher median - Math.floor((n+1)/2) of sorted%0A%09%09medAbs.sort(null);%0A%09%09double median = medAbs.getElementDoubleAbs((int)Math.floor((medAbs.getSize()+1)/2));%0A%09%09%0A%09%09return median * SNSCALEFACTOR;%0A%09%7D%0A%09%0A%09public static double lowMed(Dataset data) %7B%0A%09%09return data.getElementDoubleAbs((int)Math.floor((data.getSize()/2)+1));%0A%09%7D%0A%09%0A%09public static double highMed(Dataset data) %7B%0A%09%09return data.getElementDoubleAbs((int)Math.floor((data.getSize()+1)/2));%0A%09%7D%0A%09%0A%09%0A%7D%0A

Add outlier stats class