From commits-return-60834-archive-asf-public=cust-asf.ponee.io@commons.apache.org Fri Jan 12 14:39:55 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id AEF6D18076D for ; Fri, 12 Jan 2018 14:39:55 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 9EBE7160C30; Fri, 12 Jan 2018 13:39:55 +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 EAD13160C33 for ; Fri, 12 Jan 2018 14:39:54 +0100 (CET) Received: (qmail 45779 invoked by uid 500); 12 Jan 2018 13:39:53 -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 45750 invoked by uid 99); 12 Jan 2018 13:39:53 -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; Fri, 12 Jan 2018 13:39:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8A914E0779; Fri, 12 Jan 2018 13:39:51 +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: Fri, 12 Jan 2018 13:39:55 -0000 Message-Id: In-Reply-To: <7f1646859a4d4211ae15e588b530809e@git.apache.org> References: <7f1646859a4d4211ae15e588b530809e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [5/5] commons-rng git commit: Make branching explicit (self-documenting code). Make branching explicit (self-documenting code). Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/01a2c09c Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/01a2c09c Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/01a2c09c Branch: refs/heads/master Commit: 01a2c09ce1d475fcedbdb06d7c2e3311e9222aca Parents: daf0f7b Author: Gilles Authored: Fri Jan 12 14:38:21 2018 +0100 Committer: Gilles Committed: Fri Jan 12 14:38:21 2018 +0100 ---------------------------------------------------------------------- .../AhrensDieterMarsagliaTsangGammaSampler.java | 35 ++++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-rng/blob/01a2c09c/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java ---------------------------------------------------------------------- diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java index 146888a..7a41197 100644 --- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java +++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java @@ -114,28 +114,27 @@ public class AhrensDieterMarsagliaTsangGammaSampler } } } - } - - // Now theta >= 1. - while (true) { - final double x = gaussian.sample(); - final double oPcTx = (1 + cOptim * x); - final double v = oPcTx * oPcTx * oPcTx; + } else { + while (true) { + final double x = gaussian.sample(); + final double oPcTx = (1 + cOptim * x); + final double v = oPcTx * oPcTx * oPcTx; - if (v <= 0) { - continue; - } + if (v <= 0) { + continue; + } - final double x2 = x * x; - final double u = nextDouble(); + final double x2 = x * x; + final double u = nextDouble(); - // Squeeze. - if (u < 1 - 0.0331 * x2 * x2) { - return alpha * dOptim * v; - } + // Squeeze. + if (u < 1 - 0.0331 * x2 * x2) { + return alpha * dOptim * v; + } - if (Math.log(u) < 0.5 * x2 + dOptim * (1 - v + Math.log(v))) { - return alpha * dOptim * v; + if (Math.log(u) < 0.5 * x2 + dOptim * (1 - v + Math.log(v))) { + return alpha * dOptim * v; + } } } }