public class RandomDataGenerator extends Object implements RandomGenerator, Serializable
| Constructor and Description | 
|---|
| RandomDataGenerator()Construct a RandomDataGenerator with a default RandomGenerator as its source of random data. | 
| RandomDataGenerator(long seed)Construct a RandomDataGenerator with a default RandomGenerator as its source of random data, initialized
 with the given seed value. | 
| Modifier and Type | Method and Description | 
|---|---|
| protected RandomGenerator | delegate()Returns the backing delegate instance that methods are forwarded to. | 
| double | nextBeta(double alpha,
        double beta)Returns the next pseudo-random beta-distributed value with the given
 shape and scale parameters. | 
| boolean | nextBoolean()Returns the next pseudorandom, uniformly distributed
  booleanvalue from this random number generator's sequence. | 
| void | nextBytes(byte[] bytes)Generates random bytes and places them into a user-supplied
 byte array. | 
| void | nextBytes(byte[] bytes,
         int offset,
         int length)Generates random bytes and places them into a user-supplied
 byte array. | 
| int | nextDeviate(IntegerDistribution dist)Returns a random deviate from the given distribution. | 
| double | nextDeviate(RealDistribution dist)Returns a random deviate from the given distribution. | 
| int[] | nextDeviates(IntegerDistribution dist,
            int size)Returns an array of random deviates from the given distribution. | 
| double[] | nextDeviates(RealDistribution dist,
            int size)Returns an array of random deviates from the given distribution. | 
| double | nextDouble()Returns the next pseudorandom, uniformly distributed
  doublevalue between0.0and1.0from this random number generator's sequence. | 
| double | nextExponential(double mean)Returns the next pseudo-random, exponentially distributed deviate. | 
| float | nextFloat()Returns the next pseudorandom, uniformly distributed  floatvalue between0.0and1.0from this random
 number generator's sequence. | 
| double | nextGamma(double shape,
         double scale)Returns the next pseudo-random gamma-distributed value with the given shape and scale parameters. | 
| double | nextGaussian()Returns the next pseudorandom, Gaussian ("normally") distributed
  doublevalue with mean0.0and standard
 deviation1.0from this random number generator's sequence. | 
| String | nextHexString(int len)Generates a random string of hex characters of length  len. | 
| int | nextInt()Returns the next pseudorandom, uniformly distributed  intvalue from this random number generator's sequence. | 
| int | nextInt(int n)Returns a pseudorandom, uniformly distributed  intvalue
 between 0 (inclusive) and the specified value (exclusive), drawn from
 this random number generator's sequence. | 
| int | nextInt(int lower,
       int upper)Returns a uniformly distributed random integer between lower and upper (inclusive). | 
| double | nextLogNormal(double shape,
             double scale)Returns the next log-normally-distributed pseudo-random deviate. | 
| long | nextLong()Returns the next pseudorandom, uniformly distributed  longvalue from this random number generator's sequence. | 
| long | nextLong(long n)Returns a pseudorandom, uniformly distributed  intvalue
 between 0 (inclusive) and the specified value (exclusive), drawn from
 this random number generator's sequence. | 
| long | nextLong(long lower,
        long upper)Returns a uniformly distributed random long integer between lower and upper (inclusive). | 
| double | nextNormal(double mean,
          double standardDeviation)Returns the next normally-distributed pseudo-random deviate. | 
| int[] | nextPermutation(int n,
               int k)Generates an integer array of length  kwhose entries are selected
 randomly, without repetition, from the integers0, ..., n - 1(inclusive). | 
| int | nextPoisson(double mean)Returns a poisson-distributed deviate with the given mean. | 
| Object[] | nextSample(Collection<?> c,
          int k)Returns an array of  kobjects selected randomly from the
 Collectionc. | 
| double[] | nextSample(double[] a,
          int k)Returns an array of  kdouble values selected randomly from the
 double arraya. | 
| int[] | nextSampleWithReplacement(int sampleSize,
                         double[] weights)Generates a random sample of size sampleSize from {0, 1, ... | 
| double | nextUniform(double lower,
           double upper)Returns a double value uniformly distributed over [lower, upper] | 
| int | nextZipf(int numberOfElements,
        double exponent)Returns an integer value following a Zipf distribution with the given parameter. | 
| static RandomDataGenerator | of(RandomGenerator randomGenerator)Factory method to create a  RandomDatainstance using the suppliedRandomGenerator. | 
| void | setSeed(int seed)Sets the seed of the underlying random number generator using an
  intseed. | 
| void | setSeed(int[] seed)Sets the seed of the underlying random number generator using an
  intarray seed. | 
| void | setSeed(long seed)Sets the seed of the underlying random number generator using a
  longseed. | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitnextBoolean, nextBytes, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, nextLong, setSeed, setSeed, setSeedpublic RandomDataGenerator()
public RandomDataGenerator(long seed)
seed - seed valuepublic static RandomDataGenerator of(RandomGenerator randomGenerator)
RandomData instance using the supplied
 RandomGenerator.randomGenerator - source of random bitsMathIllegalArgumentException - if randomGenerator is nullprotected RandomGenerator delegate()
Concrete subclasses override this method to supply the instance being decorated.
public double nextBeta(double alpha,
                       double beta)
alpha - First shape parameter (must be positive).beta - Second shape parameter (must be positive).public double nextExponential(double mean)
mean - mean of the exponential distributionpublic double nextGamma(double shape,
                        double scale)
shape - shape parameter of the distributionscale - scale parameter of the distributionpublic double nextNormal(double mean,
                         double standardDeviation)
mean - mean of the normal distributionstandardDeviation - standard deviation of the normal distributionpublic double nextLogNormal(double shape,
                            double scale)
shape - shape parameter of the log-normal distributionscale - scale parameter of the log-normal distributionpublic int nextPoisson(double mean)
mean - expected valueMathIllegalArgumentException - if mean is not strictly positivepublic double nextDeviate(RealDistribution dist)
dist - the distribution to sample frompublic double[] nextDeviates(RealDistribution dist, int size)
dist - the distribution to sample fromsize - the number of values to returnsize values following the given distributionpublic int nextDeviate(IntegerDistribution dist)
dist - the distribution to sample frompublic int[] nextDeviates(IntegerDistribution dist, int size)
dist - the distribution to sample fromsize - the number of values to returnsize values following the given distributionpublic int nextInt(int lower,
                   int upper)
lower - lower bound for the generated valueupper - upper bound for the generated valueMathIllegalArgumentException - if lower is not strictly less than or equal to upperpublic long nextLong(long lower,
                     long upper)
              throws MathIllegalArgumentException
lower - lower bound for the generated valueupper - upper bound for the generated valueMathIllegalArgumentException - if lower is not strictly less than or equal to upperpublic double nextUniform(double lower,
                          double upper)
lower - lower boundupper - upper boundMathIllegalArgumentException - if upper is less than or equal to upperpublic int nextZipf(int numberOfElements,
                    double exponent)
numberOfElements - number of elements of the distributionexponent - exponent of the distributionpublic String nextHexString(int len) throws MathIllegalArgumentException
len.
 The generated string will be random, but not cryptographically secure.
Algorithm Description: hex strings are generated using a 2-step process.
len / 2 + 1 binary bytes are generated using the underlying
 Randomlen - the desired string length.MathIllegalArgumentException - if len <= 0.public int[] nextPermutation(int n,
                             int k)
                      throws MathIllegalArgumentException
k whose entries are selected
 randomly, without repetition, from the integers 0, ..., n - 1
 (inclusive).
 
 Generated arrays represent permutations of n taken k at a
 time.
MathArrays.shuffle in order to create a random shuffle of the set
 of natural numbers { 0, 1, ..., n - 1 }.n - the domain of the permutationk - the size of the permutationk-permutation of n, as an array of
 integersMathIllegalArgumentException - if k > n.MathIllegalArgumentException - if k <= 0.public Object[] nextSample(Collection<?> c, int k) throws MathIllegalArgumentException
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.
This method calls nextPermutation(c.size(), k)
 in order to sample the collection.
 
c - the collection to be sampledk - the size of the samplek elements from cMathIllegalArgumentException - if k > c.size().MathIllegalArgumentException - if k <= 0.public double[] nextSample(double[] a,
                           int k)
                    throws MathIllegalArgumentException
k double values selected randomly from the
 double array a.
 
 Sampling from a is without replacement; but if a contains
 identical objects, the sample may include repeats.  If all elements of
 a are distinct, the resulting object array represents a
 
 Simple Random Sample of size k from the elements of
 a.
a - the array to be sampledk - the size of the samplek elements from aMathIllegalArgumentException - if k > c.size().MathIllegalArgumentException - if k <= 0.public int[] nextSampleWithReplacement(int sampleSize,
                                       double[] weights)
For 0 < i < weights.length, the probability that i is selected (on any draw) is weights[i]. If necessary, the weights array is normalized to sum to 1 so that weights[i] is a probability and the array sums to 1.
Weights can be 0, but must not be negative, infinite or NaN. At least one weight must be positive.
sampleSize - size of sample to generateweights - probability sampling weightsMathIllegalArgumentException - if weights contains negative, NaN or infinite values or only 0s or sampleSize is less than 0public void setSeed(int seed)
int seed.
 Sequences of values generated starting with the same seeds should be identical.
setSeed in interface RandomGeneratorseed - the seed valuepublic void setSeed(int[] seed)
int array seed.
 Sequences of values generated starting with the same seeds should be identical.
setSeed in interface RandomGeneratorseed - the seed valuepublic void setSeed(long seed)
long seed.
 Sequences of values generated starting with the same seeds should be identical.
setSeed in interface RandomGeneratorseed - the seed valuepublic void nextBytes(byte[] bytes)
nextBytes in interface RandomGeneratorbytes - the non-null byte array in which to put the random bytespublic void nextBytes(byte[] bytes,
                      int offset,
                      int length)
nextBytes in interface RandomGeneratorbytes - the non-null byte array in which to put the random bytesoffset - the starting index for inserting the generated bytes into
 the arraylength - the number of bytes to generatepublic int nextInt()
int
 value from this random number generator's sequence.
 
 All 232 possible int values should be produced
 with (approximately) equal probability.
nextInt in interface RandomGeneratorint
 value from this random number generator's sequencepublic int nextInt(int n)
int value
 between 0 (inclusive) and the specified value (exclusive), drawn from
 this random number generator's sequence.nextInt in interface RandomGeneratorn - the bound on the random number to be returned. Must be positive.int
 value between 0 (inclusive) and n (exclusive).public long nextLong()
long
 value from this random number generator's sequence. All 264
 possible long values should be produced with (approximately)
 equal probability.nextLong in interface RandomGeneratorlong
 value from this random number generator's sequencepublic long nextLong(long n)
int value
 between 0 (inclusive) and the specified value (exclusive), drawn from
 this random number generator's sequence.nextLong in interface RandomGeneratorn - the bound on the random number to be returned. Must be positive.int
 value between 0 (inclusive) and n (exclusive).public boolean nextBoolean()
boolean value from this random number generator's sequence.nextBoolean in interface RandomGeneratorboolean value from this random number generator's
 sequencepublic float nextFloat()
float
 value between 0.0 and 1.0 from this random
 number generator's sequence.nextFloat in interface RandomGeneratorfloat
 value between 0.0 and 1.0 from this
 random number generator's sequencepublic double nextDouble()
double value between 0.0 and
 1.0 from this random number generator's sequence.nextDouble in interface RandomGeneratordouble value between 0.0 and
  1.0 from this random number generator's sequencepublic double nextGaussian()
double value with mean 0.0 and standard
 deviation 1.0 from this random number generator's sequence.nextGaussian in interface RandomGeneratordouble value with mean 0.0 and
 standard deviation 1.0 from this random number
  generator's sequenceCopyright © 2016–2020 Hipparchus.org. All rights reserved.