|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rit.util.RandomSample
public class RandomSample
Class RandomSample provides objects that generate random samples from discrete sets.
| Method Summary | |
|---|---|
static Iterator<Integer> |
withoutReplacement(Random prng,
int n,
int N)
Create an iterator that generates a random sample of ints without replacement. |
static int |
withoutReplacement(Random prng,
int n,
int N,
int[] buf)
Generate a random sample of ints without replacement. |
static Iterator<Long> |
withoutReplacement(Random prng,
int n,
long N)
Create an iterator that generates a random sample of longs without replacement. |
static int |
withoutReplacement(Random prng,
int n,
long N,
long[] buf)
Generate a random sample of longs without replacement. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static Iterator<Integer> withoutReplacement(Random prng,
int n,
int N)
As a special case, if n ≥ N, then the iterator returns all items in the set in ascending order, and the iterator does not use the prng.
The iterator uses the algorithm in A. Bissell, Ordered random selection without replacement, Applied Statistics, 35(1):73-75, 1986.
prng - Pseudorandom number generator.n - Number of items in the sample.N - Number of items in the set.
IllegalArgumentException - (unchecked exception) Thrown if n < 0 or N < 0.
public static int withoutReplacement(Random prng,
int n,
int N,
int[] buf)
As a special case, if n ≥ N, then all items in the set are stored in ascending order in the given buf starting at index 0, and the iterator does not use the prng.
This method uses the algorithm in A. Bissell, Ordered random selection without replacement, Applied Statistics, 35(1):73-75, 1986.
prng - Pseudorandom number generator.n - Number of items in the sample.N - Number of items in the set.buf - Array in which to store the sampled items.
IllegalArgumentException - (unchecked exception) Thrown if n < 0 or N < 0.
NullPointerException - (unchecked exception) Thrown if buf is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if buf.length < n.
public static Iterator<Long> withoutReplacement(Random prng,
int n,
long N)
As a special case, if n ≥ N, then the iterator returns all items in the set in ascending order, and the iterator does not use the prng.
The iterator uses the algorithm in A. Bissell, Ordered random selection without replacement, Applied Statistics, 35(1):73-75, 1986.
prng - Pseudorandom number generator.n - Number of items in the sample.N - Number of items in the set.
IllegalArgumentException - (unchecked exception) Thrown if n < 0 or N < 0.
public static int withoutReplacement(Random prng,
int n,
long N,
long[] buf)
As a special case, if n ≥ N, then all items in the set are stored in ascending order in the given buf starting at index 0, and the iterator does not use the prng.
This method uses the algorithm in A. Bissell, Ordered random selection without replacement, Applied Statistics, 35(1):73-75, 1986.
prng - Pseudorandom number generator.n - Number of items in the sample.N - Number of items in the set.buf - Array in which to store the sampled items.
IllegalArgumentException - (unchecked exception) Thrown if n < 0 or N < 0.
NullPointerException - (unchecked exception) Thrown if buf is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if buf.length < n.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||