@Test public void testPickRandomSimple() { RandomDataGenerator random = new RandomDataGenerator(new MersenneTwister(123)); List<Integer> arr = Arrays.asList(1); assertEquals(1, RandomUtils.pickRandom(arr, random).intValue()); }
public static <T> T pickRandom(List<T> items, RandomDataGenerator random) { Preconditions.checkArgument(items.size() > 0); return items.size() == 1 ? items.get(0) : items.get(nextInt(0, items.size() - 1, random)); }
RandomUtils { public static <T> T pickRandom(List<T> items, RandomDataGenerator random) { Preconditions.checkArgument(items.size() > 0); return items.size() == 1 ? items.get(0) : items.get(nextInt(0, items.size() - 1, random)); } }
RandomUtils { public static <T> T pickRandom(List<T> items, RandomDataGenerator random) { Preconditions.checkArgument(items.size() > 0); return items.size() == 1 ? items.get(0) : items.get(nextInt(0, items.size() - 1, random)); }  }
RandomUtils { public static <T> T pickRandom(List<T> items, RandomDataGenerator random) { Preconditions.checkArgument(items.size() > 0); return items.size() == 1 ? items.get(0) : items.get(nextInt(0, items.size() - 1, random)); }  static List<T> sample(List<T> items, int m, RandomDataGenerator random); static List<T> sampleMore(List<T> items, int m, RandomDataGenerator random); static List<T> sample(List<T> items, int m, Set<T> forbidden, RandomDataGenerator random); static List<T> sampleWithReplacement(List<T> items, int m, RandomDataGenerator random); static int[] shuffleInts(int[] ar, RandomDataGenerator random); static List<T> shuffle(List<T> items, RandomDataGenerator random); static List<T> randomSampleViaShuffle(Iterable<T> items, int sampleSize, RandomDataGenerator random); static int nextInt(int lower, int upper, RandomDataGenerator random); static double nextUniform(double lower, double upper, RandomDataGenerator random); static T pickRandom(List<T> items, RandomDataGenerator random); static int pickRandom(int[] arr, RandomDataGenerator random); static T pickRandom(T[] arr, RandomDataGenerator random); static double[] randomDoubleVector(int n, double minValue, double maxValue, RandomDataGenerator random); static float[] nextFloatVector(int n, float minValue, float maxValue, RandomDataGenerator random); static int sampleAccordingToDistribution(RandomDataGenerator random, double[] probabilities); }
RandomUtils { public static <T> T pickRandom(List<T> items, RandomDataGenerator random) { Preconditions.checkArgument(items.size() > 0); return items.size() == 1 ? items.get(0) : items.get(nextInt(0, items.size() - 1, random)); }  static List<T> sample(List<T> items, int m, RandomDataGenerator random); static List<T> sampleMore(List<T> items, int m, RandomDataGenerator random); static List<T> sample(List<T> items, int m, Set<T> forbidden, RandomDataGenerator random); static List<T> sampleWithReplacement(List<T> items, int m, RandomDataGenerator random); static int[] shuffleInts(int[] ar, RandomDataGenerator random); static List<T> shuffle(List<T> items, RandomDataGenerator random); static List<T> randomSampleViaShuffle(Iterable<T> items, int sampleSize, RandomDataGenerator random); static int nextInt(int lower, int upper, RandomDataGenerator random); static double nextUniform(double lower, double upper, RandomDataGenerator random); static T pickRandom(List<T> items, RandomDataGenerator random); static int pickRandom(int[] arr, RandomDataGenerator random); static T pickRandom(T[] arr, RandomDataGenerator random); static double[] randomDoubleVector(int n, double minValue, double maxValue, RandomDataGenerator random); static float[] nextFloatVector(int n, float minValue, float maxValue, RandomDataGenerator random); static int sampleAccordingToDistribution(RandomDataGenerator random, double[] probabilities);  }