Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5D5F510B4E for ; Tue, 16 Dec 2014 21:00:15 +0000 (UTC) Received: (qmail 93640 invoked by uid 500); 16 Dec 2014 21:00:14 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 93541 invoked by uid 500); 16 Dec 2014 21:00:14 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 93525 invoked by uid 99); 16 Dec 2014 21:00:14 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Dec 2014 21:00:14 +0000 Date: Tue, 16 Dec 2014 21:00:13 +0000 (UTC) From: "Luc Maisonobe (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (MATH-1153) Sampling from a 'BetaDistribution' is slow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MATH-1153?page=3Dcom.atlassian.= jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D14248= 928#comment-14248928 ]=20 Luc Maisonobe commented on MATH-1153: ------------------------------------- I have reworked the patch in order to integrate it directly into the BetaDi= stribution class. This involved a few variable renames, and I am clearly not sure I did it pr= operly. It seems the goodness of fit test failed in many cases. I finally selected = some seeds for which it succeeded, just to make some progress here. This is clearly not satisfaying. However, the patch has a side effect of making = most random generator tests fail, as they share a common test based on beta= distribution sampling. They all inherit this test from RandomDataGenerator= Test, the test is testNextInversionDeviate. So my current state of mind is that I broke something while updating the pa= tch, but I do not have the necessary skills to analyze it and even less to = fix it. Could someone look at my attempts. They are available on a MATH-1153 branch= in the git repository. In the meantime, I propose to postpone this issue after 3.4. > Sampling from a 'BetaDistribution' is slow > ------------------------------------------ > > Key: MATH-1153 > URL: https://issues.apache.org/jira/browse/MATH-1153 > Project: Commons Math > Issue Type: Improvement > Reporter: Sergei Lebedev > Priority: Minor > Fix For: 3.4 > > Attachments: ChengBetaSampler.java, ChengBetaSamplerTest.java > > > Currently the `BetaDistribution#sample` uses inverse CDF method, which is= quite slow for sampling-intensive computations. I've implemented a method = from the R. C. H. Cheng paper and it seems to work much better. Here's a si= mple microbenchmark: > {code} > o.j.b.s.SamplingBenchmark.algorithmBCorBB 1e-3 1000 thrpt = 5 2592200.015 14391.520 ops/s > o.j.b.s.SamplingBenchmark.algorithmBCorBB 1000 1000 thrpt = 5 3210800.292 33330.791 ops/s > o.j.b.s.SamplingBenchmark.commonsVersion 1e-3 1000 thrpt = 5 31034.225 438.273 ops/s > o.j.b.s.SamplingBenchmark.commonsVersion 1000 1000 thrpt = 5 21834.010 433.324 ops/s > {code} > Should I submit a patch? > R. C. H. Cheng (1978). Generating beta variates with nonintegral shape pa= rameters. Communications of the ACM, 21, 317=E2=80=93322. -- This message was sent by Atlassian JIRA (v6.3.4#6332)