Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DC769200B7F for ; Sat, 27 Aug 2016 22:15:32 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id DB1E1160AB2; Sat, 27 Aug 2016 20:15:32 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2DDA1160A93 for ; Sat, 27 Aug 2016 22:15:32 +0200 (CEST) Received: (qmail 41680 invoked by uid 500); 27 Aug 2016 20:15:16 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 38006 invoked by uid 99); 27 Aug 2016 20:15:14 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Aug 2016 20:15:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DBADAEEF4D; Sat, 27 Aug 2016 20:15:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: erans@apache.org To: commits@commons.apache.org Date: Sat, 27 Aug 2016 20:15:54 -0000 Message-Id: <951d7e3227554e3f9a61691f9fdc18e0@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [43/44] [math] MATH-1383 archived-at: Sat, 27 Aug 2016 20:15:33 -0000 MATH-1383 Update userguide: removing reference to deleted package "o.a.c.math4.rng". Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/d52a020e Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/d52a020e Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/d52a020e Branch: refs/heads/develop Commit: d52a020ef7bdc98ba2ba88a8e2bdd412d30a930c Parents: e2423a4 Author: Gilles Authored: Sun Aug 28 00:06:51 2016 +0200 Committer: Gilles Committed: Sun Aug 28 00:06:51 2016 +0200 ---------------------------------------------------------------------- src/site/site.xml | 1 - src/site/xdoc/userguide/random.xml | 45 +++++++++++++-------------------- 2 files changed, 18 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/d52a020e/src/site/site.xml ---------------------------------------------------------------------- diff --git a/src/site/site.xml b/src/site/site.xml index 22fefe6..b6e0f7a 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -76,7 +76,6 @@ - http://git-wip-us.apache.org/repos/asf/commons-math/blob/d52a020e/src/site/xdoc/userguide/random.xml ---------------------------------------------------------------------- diff --git a/src/site/xdoc/userguide/random.xml b/src/site/xdoc/userguide/random.xml index 8ef9f84..868c96a 100644 --- a/src/site/xdoc/userguide/random.xml +++ b/src/site/xdoc/userguide/random.xml @@ -49,14 +49,8 @@ These utilities rely on an underlying "source of randomness", which in most cases is a pseudo-random number generator (PRNG) that produces sequences of numbers that are uniformly distributed within their range. - Commons Math provides many PRNG implementations that share a common - interface: - - UniformRandomProvider (for more details about this interface and the - available RNG algorithms, please refer to the Javadoc of package - - org.apache.commons.math4.rng and this section - of the userguide. + Commons Math depends on Commons Rng + for the PRNG implementations.

A PRNG algorithm is often deterministic, i.e. it produces the same sequence @@ -96,23 +90,20 @@

It is possible for a sequence of numbers to appear random, but nonetheless to be predictable based on the algorithm used to generate the - sequence. If in addition to randomness, strong unpredictability is - required, it is best to use a + sequence. + When in addition to randomness, strong unpredictability is + required, a - secure random number generator to generate values (or strings). - - Most PRNG implemented in this library are not secure in that sense, except - perhaps the - ISAAC generator. - An alternative is to use an instance of the JDK-provided SecureRandom - generator. + secure random number generator + should be used to generate values (or strings), for example an instance of + the JDK-provided SecureRandom generator. In general, such secure generator produce sequence based on a source of true randomness, and sequences started with the same seed will diverge. The RandomUtils - class provides a "factory" method to wrap java.util.Random or - java.security.SecureRandom instances in an object that implements - the + class provides a method for wrapping a java.util.Random or + java.security.SecureRandom instance in an object that implements + the UniformRandomProvider interface: UniformRandomProvider rg = RandomUtils.asUniformRandomProvider(new java.security.SecureRandom()); @@ -151,21 +142,21 @@ UniformRandomProvider rg = RandomUtils.asUniformRandomProvider(new java.security
Generating random vectors from a bivariate normal distribution
// Import common PRNG interface and factory class that instantiates the PRNG. -import org.apache.commons.math4.rng.UniformRandomProvider; -import org.apache.commons.math4.rng.RandomSource; +import org.apache.commons.rng.UniformRandomProvider; +import org.apache.commons.rng.RandomSource; -// Create (and possibly seed) a PRNG (could use any of the CM-provided generators) +// Create (and possibly seed) a PRNG (could use any of the CM-provided generators). long seed = 17399225432L; // Fixed seed means same results every time UniformRandomProvider rg = RandomSource.create(RandomSource.MT, seed); -// Create a GassianRandomGenerator using rg as its source of randomness +// Create a GaussianRandomGenerator using "rg" as its source of randomness. GaussianRandomGenerator rawGenerator = new GaussianRandomGenerator(rg); -// Create a CorrelatedRandomVectorGenerator using rawGenerator for the components +// Create a CorrelatedRandomVectorGenerator using "rawGenerator" for the components. CorrelatedRandomVectorGenerator generator = new CorrelatedRandomVectorGenerator(mean, covariance, 1.0e-12 * covariance.getNorm(), rawGenerator); -// Use the generator to generate correlated vectors +// Use the generator to generate correlated vectors. double[] randomVector = generator.nextVector(); ... @@ -181,7 +172,7 @@ double[] randomVector = generator.nextVector(); double[] mean = {1, 2}; double[][] cov = {{9, c}, {c, 16}}; RealMatrix covariance = MatrixUtils.createRealMatrix(cov); - where c is the desired covariance. If you are starting with a desired correlation, + where "c" is the desired covariance. If you are starting with a desired correlation, you need to translate this to a covariance by multiplying it by the product of the standard deviations. For example, if you want to generate data that will give Pearson's R of 0.5, you would use c = 3 * 4 * 0.5 = 6.