Currently the [rng] sampler package can only shuffle primitive int[] arrays:
o.a.c.rng.sampling.PermutationSampler: public static void shuffle(UniformRandomProvider rng, int[] list) public static void shuffle(UniformRandomProvider rng, int[] list, int start, boolean towardHead) I would like to be able to shuffle other arrays such as double[]. There is actually this functionality in [Lang] o.a.c.lang3.ArrayUtils. However it uses java.util.Random for the random source, and does not support a sub-range, e.g. public static void shuffle(final byte[] array) public static void shuffle(final byte[] array, final Random random) I suggest an API that requires UniformRandomProvider and can handle sub-ranges as: public static void shuffle(UniformRandomProvider rng, int[] data); public static void shuffle(UniformRandomProvider rng, int[] data, int from, int to); Or (similar to java.util.Arrays.copyOfRange): public static void shuffleOfRange(UniformRandomProvider rng, int[] data, int from, int to); This can be repeated for all 8 primitive types and generic type T. I suggest putting this in the sampling package but under what class? Note that all public class names in the sampling package currently end in Sampler. I would suggest ArraySampler. Note there is currently a ListSampler which has generic methods to return List<T> samples from a list, and shuffle lists. So adding ArraySampler with only shuffling would be missing equivalent sample methods. Consistency would require adding 8 variations of sample and a generic one: public static double[] sample(UniformRandomProvider rng, double[] array, int k) { public static <T> T[] sample(UniformRandomProvider rng, T[] array, int k) I have no use case for this but can add it for completeness. Alex --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org