From 5df86e5cb2d7c36935f3a640ae4aa29c93b6b152 Mon Sep 17 00:00:00 2001 From: Phil Steitz Date: Mon, 11 Nov 2013 18:51:38 +0000 Subject: [PATCH] Removed reference to deprecated class. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1540802 13f79535-47bb-0310-9956-ffa450edef68 --- src/site/xdoc/userguide/random.xml | 51 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/site/xdoc/userguide/random.xml b/src/site/xdoc/userguide/random.xml index 27f335418..dd69d7985 100644 --- a/src/site/xdoc/userguide/random.xml +++ b/src/site/xdoc/userguide/random.xml @@ -68,8 +68,8 @@

- The - RandomData interface defines methods for generating random sequences + The + RandomDataGenerator class implements methods for generating random sequences of numbers. The API contracts of these methods use the following concepts:

Random sequence of numbers from a probability distribution
@@ -90,8 +90,8 @@ distributions package. The javadoc for the nextXxx methods in - - RandomDataImpl describes the algorithms used to generate + + RandomDataGenerator describes the algorithms used to generate random deviates.
Cryptographically secure random sequences
@@ -101,33 +101,32 @@ required, it is best to use a secure random number generator to generate values (or strings). The - nextSecureXxx methods in the RandomDataImpl implementation of - the RandomData interface use the JDK SecureRandom - PRNG to generate cryptographically secure sequences. The - setSecureAlgorithm method allows you to change the underlying - PRNG. These methods are much slower than the corresponding - "non-secure" versions, so they should only be used when cryptographic + nextSecureXxx methods implemented by RandomDataGenerator + use the JDK SecureRandom PRNG to generate cryptographically + secure sequences. The setSecureAlgorithm method allows you to + change the underlying PRNG. These methods are much slower than + the corresponding "non-secure" versions, so they should only be used when cryptographic security is required. The ISAACRandom class implements a fast - cryptographically secure pseudorandom numbers generator. + cryptographically secure pseudorandom number generator.
Seeding pseudo-random number generators
-
By default, the implementation provided in RandomDataImpl +
By default, the implementation provided in RandomDataGenerator uses the JDK-provided PRNG. Like most other PRNGs, the JDK generator - generates sequences of random numbers based on an initial "seed value". + generates sequences of random numbers based on an initial "seed value." For the non-secure methods, starting with the same seed always produces the same sequence of values. Secure sequences started with the same seeds will - diverge. When a new RandomDataImpl is created, the underlying + diverge. When a new RandomDataGenerator is created, the underlying random number generators are not initialized. The first - call to a data generation method, or to a reSeed() method + call to a data generation method, or to a reSeed() method initializes the appropriate generator. If you do not explicitly seed the generator, it is by default seeded with the current time in milliseconds. Therefore, to generate sequences of random data values, you should always - instantiate one RandomDataImpl and use it + instantiate one RandomDataGenerator and use it repeatedly instead of creating new instances for subsequent values in the sequence. For example, the following will generate a random sequence of 50 long integers between 1 and 1,000,000, using the current time in milliseconds as the seed for the JDK PRNG: -RandomData randomData = new RandomDataImpl(); +RandomDataGenerator randomData = new RandomDataGenerator(); for (int i = 0; i < 1000; i++) { value = randomData.nextLong(1, 1000000); } @@ -137,14 +136,14 @@ for (int i = 0; i < 1000; i++) { milliseconds: for (int i = 0; i < 1000; i++) { - RandomDataImpl randomData = new RandomDataImpl(); + RandomDataGenerator randomData = new RandomDataGenerator(); value = randomData.nextLong(1, 1000000); } The following will produce the same random sequence each time it is executed: -RandomData randomData = new RandomDataImpl(); +RandomDataGenerator randomData = new RandomDataGenerator(); randomData.reSeed(1000); for (int i = 0; i = 1000; i++) { value = randomData.nextLong(1, 1000000); @@ -153,7 +152,7 @@ for (int i = 0; i = 1000; i++) { The following will produce a different random sequence each time it is executed. -RandomData randomData = new RandomDataImpl(); +RandomDataGenerator randomData = new RandomDataGenerator(); randomData.reSeedSecure(1000); for (int i = 0; i < 1000; i++) { value = randomData.nextSecureLong(1, 1000000); @@ -262,12 +261,12 @@ double[] randomVector = generator.nextVector(); of these methods produce sequences of strings with good dispersion properties. The difference between the two methods is that the second is cryptographically secure. Specifically, the implementation of - nextHexString(n) in RandomDataImpl uses the + nextHexString(n) in RandomDataGenerator uses the following simple algorithm to generate a string of n hex digits:
    -
  1. n/2+1 binary bytes are generated using the underlying Random
  2. +
  3. n/2+1 binary bytes are generated using the underlying RandomGenerator
  4. Each binary byte is translated into 2 hex digits
- The RandomDataImpl implementation of the "secure" version, + The RandomDataGenerator implementation of the "secure" version, nextSecureHexString generates hex characters in 40-byte "chunks" using a 3-step process:
    @@ -289,10 +288,10 @@ double[] randomVector = generator.nextVector(); href="combinatorics">

    To select a random sample of objects in a collection, you can use the - nextSample method in the RandomData interface. + nextSample method implemented by RandomDataGenerator. Specifically, if c is a collection containing at least k objects, and randomData is a - RandomData instance randomData.nextSample(c, k) + RandomDataGenerator instance randomData.nextSample(c, k) will return an object[] array of length k consisting of elements randomly selected from the collection. If c contains duplicate references, there may be duplicate @@ -300,7 +299,7 @@ double[] randomVector = generator.nextVector(); unique -- i.e., the sampling is without replacement among the object references in the collection.

    - If randomData is a RandomData instance, and + If randomData is a RandomDataGenerator instance, and n and k are integers with k <= n, then randomData.nextPermutation(n, k) returns an int[]