public class RandomSample extends Object
Modifier and Type | Field and Description |
---|---|
private int |
n |
private long |
N |
private Random |
rand |
Constructor and Description |
---|
RandomSample(long N,
int n)
Create a new generator of random samples of
n distinct values
from the numbers 1 to N . |
Modifier and Type | Method and Description |
---|---|
static void |
main(String[] args)
The main program for the RandomSample class
|
long[] |
nextSample()
Return a random sample.
|
public RandomSample(long N, int n)
n
distinct values
from the numbers 1 to N
.N
- specifies the range from which we
want a sample, the range will be 1...N
.n
- specifies the size of the sample, the
sample will contain distinct values in the range specified by N
.public long[] nextSample()
n
numbers sampled from the numbers 1...
N
.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses