/** * Samples a a given number of items from a list with replacement. * * @param <DataType> * The type of data in the list. * @param random * The random number generator. * @param data * The list to sample from. * @param sampleSize * The sample size. Must be positive. * @return * An array list of the given size sampled with replacement from the * given data. */ public static <DataType> ArrayList<DataType> sampleWithReplacement( final Random random, final List<? extends DataType> data, final int sampleSize) { final ArrayList<DataType> result = new ArrayList<DataType>(sampleSize); sampleWithReplacementInto(random, data, sampleSize, result); return result; }
/** * Samples a a given number of items from a list with replacement. * * @param <DataType> * The type of data in the list. * @param random * The random number generator. * @param data * The list to sample from. * @param sampleSize * The sample size. Must be positive. * @return * An array list of the given size sampled with replacement from the * given data. */ public static <DataType> ArrayList<DataType> sampleWithReplacement( final Random random, final List<? extends DataType> data, final int sampleSize) { final ArrayList<DataType> result = new ArrayList<DataType>(sampleSize); sampleWithReplacementInto(random, data, sampleSize, result); return result; }
/** * Samples a a given number of items from a list with replacement. * * @param <DataType> * The type of data in the list. * @param random * The random number generator. * @param data * The list to sample from. * @param sampleSize * The sample size. Must be positive. * @return * An array list of the given size sampled with replacement from the * given data. */ public static <DataType> ArrayList<DataType> sampleWithReplacement( final Random random, final List<? extends DataType> data, final int sampleSize) { final ArrayList<DataType> result = new ArrayList<DataType>(sampleSize); sampleWithReplacementInto(random, data, sampleSize, result); return result; }