On 11/27/15 5:16 AM, Gilles wrote: > Hi Phil. > > On Fri, 27 Nov 2015 01:32:22 +0000 (UTC), pste...@apache.org wrote: >> Repository: commons-math >> Updated Branches: >> refs/heads/MATH_3_X 3cfafe051 -> 654d7232e >> >> >> Modified KolmogororSmirnovTest 2-sample test to use random jitter to >> break ties in input data. JIRA: MATH-1246. >> >> >> [...] >> + >> + /** >> + * Adds random jitter to {@code data} using deviates sampled >> from {@code dist}. >> + * <p> >> + * Note that jitter is applied in-place - i.e., the array >> + * values are overwritten with the result of applying >> jitter.</p> >> + * >> + * @param data input/output data array - entries overwritten by >> the method >> + * @param dist probability distribution to sample for jitter >> values >> + * @throws NullPointerException if either of the parameters >> is null >> + */ >> + private static void jitter(double[] data, RealDistribution >> dist) { >> + for (int i = 0; i < data.length; i++) { >> + data[i] = data[i] + dist.sample(); >> + } >> + } >> } > > I think that we should prefer the "+=" operator here.
OK. I will change this. > > >> [...] >> + /** >> + * Returns an array consisting of the unique values in >> {@code data}. >> + * The return array is sorted in descending order. Empty >> arrays >> + * are allowed, but null arrays result in NullPointerException. >> + * Infinities are allowed. NaN values are allowed with maximum >> + * sort order - i.e., if there are NaN values in {@code data}, >> + * {@code Double.NaN} will be the first element of the >> output array, >> + * even if the array also contains {@code >> Double.POSITIVE_INFINITY}. >> + * >> + * @param data array to scan >> + * @return descending list of values included in the input >> array >> + * @throws NullPointerException if data is null >> + * @since 3.6 >> + */ >> + public static double[] unique(double[] data) { >> + TreeSet<Double> values = new TreeSet<Double>(); >> + for (int i = 0; i < data.length; i++) { >> + values.add(data[i]); >> + } >> + final int count = values.size(); >> + final double[] out = new double[count]; >> + Iterator<Double> iterator = values.iterator(); >> + int i = 0; >> + while (iterator.hasNext()) { >> + out[count - ++i] = iterator.next(); >> + } >> + return out; >> + } >> } > > Any reason why the implemenation of "unique" is not the same as in > "master"? The descendingIterator used in master is 1.6. Thanks for the review! Phil > > Regards, > Gilles > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org