### Question:
MathUtil { public static final <T> Object[] randomPick(Collection<T> collection, int count) { if (collection == null || collection.size() == 0 || count < 0 || count > collection.size()) { return new Object[0]; } if (count == collection.size()) { return collection.toArray(); } return randomData.nextSample(collection, count); }  static final double nextDouble(); static final double nextGaussionDouble(); static final double nextGaussionDouble(double u, double q); static final int nextGaussionInt(int low, int high); static final int nextGaussionInt(int low, int high, double q); static final int nextGaussionInt2(int low, int high, double q); static final int nextFakeInt(int max); static final int[] nextPermuate(int n, int k); static final Object[] randomPick(Collection<T> collection,
			int count); static final List<T> randomPickShuffle(Collection<T> collection,
			int count); static final Collection<T> randomPickGaussion(
			Collection<T> collection, int count, double q); static final double solveCubicEquation(double a, double b, double c, double d);  }### Answer:
@Test public void testNextSample() throws Exception { ArrayList list = new ArrayList(); for ( int i = 0; i<10; i++ ) { list.add(i); } Object[] ints = MathUtil.randomPick(list, 2); for (int i = 0; i < ints.length; i++) { System.out.println("ints["+i+"] = " + ints[i]); } }
@Test public void testNextSampleAll() throws Exception { ArrayList list = new ArrayList(); for ( int i = 0; i<10; i++ ) { list.add(i); } Object[] ints = MathUtil.randomPick(list, list.size()); for (int i = 0; i < ints.length; i++) { System.out.println("ints["+i+"] = " + ints[i]); } }
@Test public void testRandomPick() throws Exception { ArrayList list = new ArrayList(); int count = 10; for (int i = 0; i < count; i++) { Object[] rewards = MathUtil.randomPick(RewardType.TYPES, 1); System.out.println("rewards["+i+"] = " + rewards[0]); } }
@Test public void testNextSampleRatio() throws Exception { ArrayList<Integer> list = new ArrayList<Integer>(); for ( int i = 0; i<10; i++ ) { list.add(i); } int max = 10000; int[] ratio = new int[10]; for (int i = 0; i < max; i++) { Object[] ints = MathUtil.randomPick(list, 1); int index = (Integer)ints[0]; ratio[index]++; } printRatio(ratio, max); }