/** * Find the first quantile (p = 1/4) of an array of type float. The input array will * be rearranged. */ public static float q1(float[] a) { return QuickSelect.q1(a); }
/** * Find the first quantile (p = 1/4) of an array of type int. The input array will * be rearranged. */ public static int q1(int[] a) { return QuickSelect.q1(a); }
/** * Find the first quantile (p = 1/4) of an array of type double. The input array will * be rearranged. */ public static double q1(double[] a) { return QuickSelect.q1(a); }
/** * Find the first quantile (p = 1/4) of an array of type double. The input array will * be rearranged. */ public static <T extends Comparable<? super T>> T q1(T[] a) { return QuickSelect.q1(a); }
@Override public void learn(Attribute[] attributes, double[][] data) { int n = data.length; int p = data[0].length; mu = new double[p]; std = new double[p]; double[] x = new double[n]; for (int j = 0; j < p; j++) { if (attributes[j].getType() != Attribute.Type.NUMERIC) { mu[j] = Double.NaN; } else { for (int i = 0; i < n; i++) { x[i] = data[i][j]; } mu[j] = QuickSelect.median(x); std[j] = QuickSelect.q3(x) - QuickSelect.q1(x); if (Math.isZero(std[j])) { throw new IllegalArgumentException("Column " + j + " has constant values between Q1 and Q3."); } } } }