public interface RandomData
Modifier and Type | Method and Description |
---|---|
double |
nextExponential(double mean)
Generates a random value from the exponential distribution
with expected value =
mean . |
double |
nextGaussian(double mu,
double sigma)
Generates a random value from the
Normal (or Gaussian) distribution with the given mean
and standard deviation.
|
java.lang.String |
nextHexString(int len)
Generates a random string of hex characters of length
len . |
int |
nextInt(int lower,
int upper)
Generates a uniformly distributed random integer between
lower and upper (endpoints included). |
long |
nextLong(long lower,
long upper)
Generates a uniformly distributed random long integer between
lower and upper (endpoints included). |
int[] |
nextPermutation(int n,
int k)
Generates an integer array of length
k whose entries
are selected randomly, without repetition, from the integers
0 through n-1 (inclusive). |
long |
nextPoisson(double mean)
Generates a random value from the Poisson distribution with
the given mean.
|
java.lang.Object[] |
nextSample(java.util.Collection<?> c,
int k)
Returns an array of
k objects selected randomly
from the Collection c . |
java.lang.String |
nextSecureHexString(int len)
Generates a random string of hex characters from a secure random
sequence.
|
int |
nextSecureInt(int lower,
int upper)
Generates a uniformly distributed random integer between
lower and upper (endpoints included)
from a secure random sequence. |
long |
nextSecureLong(long lower,
long upper)
Generates a random long integer between
lower
and upper (endpoints included). |
double |
nextUniform(double lower,
double upper)
Generates a uniformly distributed random value from the open interval
(
lower ,upper ) (i.e., endpoints excluded). |
java.lang.String nextHexString(int len)
len
.
The generated string will be random, but not cryptographically
secure. To generate cryptographically secure strings, use
nextSecureHexString
Preconditions:
len > 0
(otherwise an IllegalArgumentException
is thrown.)len
- the length of the string to be generatedlen
int nextInt(int lower, int upper)
lower
and upper
(endpoints included).
The generated integer will be random, but not cryptographically secure.
To generate cryptographically secure integer sequences, use
nextSecureInt
.
Preconditions:
lower < upper
(otherwise an IllegalArgumentException
is thrown.)lower
- lower bound for generated integerupper
- upper bound for generated integerlower
and less than or equal to upper
.long nextLong(long lower, long upper)
lower
and upper
(endpoints included).
The generated long integer values will be random, but not
cryptographically secure.
To generate cryptographically secure sequences of longs, use
nextSecureLong
Preconditions:
lower < upper
(otherwise an IllegalArgumentException
is thrown.)lower
- lower bound for generated integerupper
- upper bound for generated integerlower
and less than or equal to upper
.java.lang.String nextSecureHexString(int len)
If cryptographic security is not required,
use nextHexString()
.
Preconditions:
len > 0
(otherwise an IllegalArgumentException
is thrown.)len
- length of return stringint nextSecureInt(int lower, int upper)
lower
and upper
(endpoints included)
from a secure random sequence.
Sequences of integers generated using this method will be
cryptographically secure. If cryptographic security is not required,
nextInt
should be used instead of this method.
Definition: Secure Random Sequence
Preconditions:
lower < upper
(otherwise an IllegalArgumentException
is thrown.)lower
- lower bound for generated integerupper
- upper bound for generated integerlower
and less than or equal to upper
.long nextSecureLong(long lower, long upper)
lower
and upper
(endpoints included).
Sequences of long values generated using this method will be
cryptographically secure. If cryptographic security is not required,
nextLong
should be used instead of this method.
Definition: Secure Random Sequence
Preconditions:
lower < upper
(otherwise an IllegalArgumentException
is thrown.)lower
- lower bound for generated integerupper
- upper bound for generated integerlower
and less than or equal to upper
.long nextPoisson(double mean)
Definition: Poisson Distribution
Preconditions:
mean
- Mean of the distributiondouble nextGaussian(double mu, double sigma)
Definition: Normal Distribution
Preconditions:
sigma > 0
(otherwise an IllegalArgumentException
is thrown.)mu
- Mean of the distributionsigma
- Standard deviation of the distributiondouble nextExponential(double mean)
mean
.
Definition: Exponential Distribution
Preconditions:
mu >= 0
(otherwise an IllegalArgumentException
is thrown.)mean
- Mean of the distributiondouble nextUniform(double lower, double upper)
lower
,upper
) (i.e., endpoints excluded).
Definition:
Uniform Distribution lower
and
upper - lower
are the
location and scale parameters, respectively.
Preconditions:
lower < upper
(otherwise an IllegalArgumentException
is thrown.)lower
- lower endpoint of the interval of supportupper
- upper endpoint of the interval of supportint[] nextPermutation(int n, int k)
k
whose entries
are selected randomly, without repetition, from the integers
0 through n-1
(inclusive).
Generated arrays represent permutations
of n
taken k
at a time.
Preconditions:
k <= n
n > 0
n
- domain of the permutationk
- size of the permutationjava.lang.Object[] nextSample(java.util.Collection<?> c, int k)
k
objects selected randomly
from the Collection c
.
Sampling from c
is without replacement; but if c
contains identical
objects, the sample may include repeats. If all elements of
c
are distinct, the resulting object array represents a
Simple Random Sample of size
k
from the elements of c
.
Preconditions:
c
- collection to be sampledk
- size of the sampleCopyright © 2010 - 2020 Adobe. All Rights Reserved