public class RandomTools
extends java.lang.Object
| Constructor and Description |
|---|
RandomTools() |
| Modifier and Type | Method and Description |
|---|---|
static int |
binomial(int n,
double p,
java.util.Random rnd)
Returns a pseudorandom number drawn from binomial distribution B(n, p).
|
static double |
exponential(java.util.Random rnd)
Returns a pseudorandom number drawn from exponential distribution with
mean 1.
|
static java.util.Set<java.lang.Integer> |
randomKsubset(int n,
int k,
java.util.Set<java.lang.Integer> subset,
java.util.Random rnd)
Generates a pseudorandom subset of size k of the set {0, 1,...
|
static java.util.Set<java.lang.Integer> |
randomPsubset(int n,
double p,
java.util.Set<java.lang.Integer> subset,
java.util.Random rnd)
Generates a pseudorandom subset of the set {0, 1,...
|
public static double exponential(java.util.Random rnd)
rnd - source of randomnesspublic static int binomial(int n,
double p,
java.util.Random rnd)
n - number of triesp - success probabilityrnd - source of randomnesspublic static java.util.Set<java.lang.Integer> randomKsubset(int n,
int k,
java.util.Set<java.lang.Integer> subset,
java.util.Random rnd)
n - the size of the initial setk - the size of the generated setsubset - if not null, this set is cleared and the result is stored
here. This avoids creations of sets at each call of this
methodrnd - source of randomnesspublic static java.util.Set<java.lang.Integer> randomPsubset(int n,
double p,
java.util.Set<java.lang.Integer> subset,
java.util.Random rnd)
n - the size of the initial setp - the probability to choose each elementsubset - if not null, this set is cleared and the result is stored
here. This avoids creations of sets at each call of this
methodrnd - source of randomness