org.apache.commons.math3.random

## Interface RandomData

- All Known Implementing Classes:
    RandomDataImpl

      public interface RandomData

  Random data generation utilities.
  Version:
    $Id: RandomData.java 1244107 2012-02-14 16:17:55Z erans $

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `nextExponential(double mean)` Generates a random value from the exponential distribution with specified mean.
    `double` | `nextGaussian(double mu, double sigma)` Generates a random value from the Normal (or Gaussian) distribution with specified mean and standard deviation.
    `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, ..., n - 1` (inclusive).
    `long` | `nextPoisson(double mean)` Generates a random value from the Poisson distribution with the given mean.
    `Object[]` | `nextSample(Collection<?> c, int k)` Returns an array of `k` objects selected randomly from the Collection `c`.
    `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 uniformly distributed random long integer between `lower` and `upper` (endpoints included) from a secure random sequence.
    `double` | `nextUniform(double lower, double upper)` Generates a uniformly distributed random value from the open interval `(lower, upper)` (i.e., endpoints excluded).
    `double` | `nextUniform(double lower, double upper, boolean lowerInclusive)` Generates a uniformly distributed random value from the interval `(lower, upper)` or the interval `[lower, upper)`.

- - ### Method Detail

    - #### nextHexString

          String nextHexString(int len)

      Generates a random string of hex characters of length `len`.

      The generated string will be random, but not cryptographically secure. To generate cryptographically secure strings, use `nextSecureHexString(int)`.

      Parameters:
        `len` - the length of the string to be generated
      Returns:
        a random string of hex characters of length `len`
      Throws:
        `NotStrictlyPositiveException` - if `len <= 0`

    - #### nextInt

          int nextInt(int lower,
                    int upper)

      Generates a uniformly distributed random integer between `lower` and `upper` (endpoints included).

      The generated integer will be random, but not cryptographically secure. To generate cryptographically secure integer sequences, use `nextSecureInt(int, int)`.

      Parameters:
        `lower` - lower bound for generated integer
        `upper` - upper bound for generated integer
      Returns:
        a random integer greater than or equal to `lower` and less than or equal to `upper`
      Throws:
        `NumberIsTooLargeException` - if `lower >= upper`

    - #### nextLong

          long nextLong(long lower,
                      long upper)

      Generates a uniformly distributed random long integer between `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(long, long)`.

      Parameters:
        `lower` - lower bound for generated long integer
        `upper` - upper bound for generated long integer
      Returns:
        a random long integer greater than or equal to `lower` and less than or equal to `upper`
      Throws:
        `NumberIsTooLargeException` - if `lower >= upper`.

    - #### nextSecureHexString

          String nextSecureHexString(int len)

      Generates a random string of hex characters from a secure random sequence.

      If cryptographic security is not required, use `nextHexString(int)`.

      Parameters:
        `len` - the length of the string to be generated
      Returns:
        a random string of hex characters of length `len`
      Throws:
        `NotStrictlyPositiveException` - if `len <= 0`

    - #### nextSecureInt

          int nextSecureInt(int lower,
                          int upper)

      Generates a uniformly distributed random integer between `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(int, int)` should be used instead of this method.

      Definition: Secure Random Sequence

      Parameters:
        `lower` - lower bound for generated integer
        `upper` - upper bound for generated integer
      Returns:
        a random integer greater than or equal to `lower` and less than or equal to `upper`.
      Throws:
        `NumberIsTooLargeException` - if `lower >= upper`.

    - #### nextSecureLong

          long nextSecureLong(long lower,
                            long upper)

      Generates a uniformly distributed random long integer between `lower` and `upper` (endpoints included) from a secure random sequence.

      Sequences of long values generated using this method will be cryptographically secure. If cryptographic security is not required, `nextLong(long, long)` should be used instead of this method.

      Definition: Secure Random Sequence

      Parameters:
        `lower` - lower bound for generated integer
        `upper` - upper bound for generated integer
      Returns:
        a random long integer greater than or equal to `lower` and less than or equal to `upper`.
      Throws:
        `NumberIsTooLargeException` - if `lower >= upper`.

    - #### nextPoisson

          long nextPoisson(double mean)

      Generates a random value from the Poisson distribution with the given mean.

      Definition: Poisson Distribution

      Parameters:
        `mean` - the mean of the Poisson distribution
      Returns:
        a random value following the specified Poisson distribution
      Throws:
        `NotStrictlyPositiveException` - if `mean <= 0`.

    - #### nextGaussian

          double nextGaussian(double mu,
                            double sigma)

      Generates a random value from the Normal (or Gaussian) distribution with specified mean and standard deviation.

      Definition: Normal Distribution

      Parameters:
        `mu` - the mean of the distribution
        `sigma` - the standard deviation of the distribution
      Returns:
        a random value following the specified Gaussian distribution
      Throws:
        `NotStrictlyPositiveException` - if `sigma <= 0`.

    - #### nextExponential

          double nextExponential(double mean)

      Generates a random value from the exponential distribution with specified mean.

      Definition: Exponential Distribution

      Parameters:
        `mean` - the mean of the distribution
      Returns:
        a random value following the specified exponential distribution
      Throws:
        `NotStrictlyPositiveException` - if `mean <= 0`.

    - #### nextUniform

          double nextUniform(double lower,
                           double upper)

      Generates a uniformly distributed random value from the open interval `(lower, upper)` (i.e., endpoints excluded).

      Definition: Uniform Distribution `lower` and `upper - lower` are the location and scale parameters, respectively.

      Parameters:
        `lower` - the exclusive lower bound of the support
        `upper` - the exclusive upper bound of the support
      Returns:
        a uniformly distributed random value between lower and upper (exclusive)
      Throws:
        `NumberIsTooLargeException` - if `lower >= upper`

    - #### nextUniform

          double nextUniform(double lower,
                           double upper,
                           boolean lowerInclusive)

      Generates a uniformly distributed random value from the interval `(lower, upper)` or the interval `[lower, upper)`. The lower bound is thus optionally included, while the upper bound is always excluded.

      Definition: Uniform Distribution `lower` and `upper - lower` are the location and scale parameters, respectively.

      Parameters:
        `lower` - the lower bound of the support
        `upper` - the exclusive upper bound of the support
        `lowerInclusive` - `true` if the lower bound is inclusive
      Returns:
        uniformly distributed random value in the `(lower, upper)` interval, if `lowerInclusive` is `false`, or in the `[lower, upper)` interval, if `lowerInclusive` is `true`
      Throws:
        `NumberIsTooLargeException` - if `lower >= upper`

    - #### nextPermutation

          int[] nextPermutation(int n,
                              int k)

      Generates an integer array of length `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.

      Parameters:
        `n` - the domain of the permutation
        `k` - the size of the permutation
      Returns:
        a random `k`-permutation of `n`, as an array of integers
      Throws:
        `NumberIsTooLargeException` - if `k > n`.
        `NotStrictlyPositiveException` - if `k <= 0`.

    - #### nextSample

          Object[] nextSample(Collection<?> c,
                            int k)

      Returns an array of `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`.

      Parameters:
        `c` - the collection to be sampled
        `k` - the size of the sample
      Returns:
        a random sample of `k` elements from `c`
      Throws:
        `NumberIsTooLargeException` - if `k > c.size()`.
        `NotStrictlyPositiveException` - if `k <= 0`.

Copyright © 2003-2012 The Apache Software Foundation. All Rights Reserved.