public class RandomTools extends Object
| Constructor and Description |
|---|
RandomTools() |
| Modifier and Type | Method and Description |
|---|---|
static int |
binomial(int n,
double p,
Random rnd)
Returns a pseudorandom number drawn from binomial distribution B(n, p).
|
static double |
exponential(Random rnd)
Returns a pseudorandom number drawn from exponential distribution with
mean 1.
|
static Set<Integer> |
randomKsubset(int n,
int k,
Set<Integer> subset,
Random rnd)
Generates a pseudorandom subset of size k of the set {0, 1,...
|
static Set<Integer> |
randomPsubset(int n,
double p,
Set<Integer> subset,
Random rnd)
Generates a pseudorandom subset of the set {0, 1,...
|
public static double exponential(Random rnd)
rnd - source of randomnesspublic static int binomial(int n,
double p,
Random rnd)
n - number of triesp - success probabilityrnd - source of randomnesspublic static Set<Integer> randomKsubset(int n, int k, Set<Integer> subset, 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 Set<Integer> randomPsubset(int n, double p, Set<Integer> subset, 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 randomnessCopyright © 2015. All rights reserved.