[ https://issues.apache.org/jira/browse/MATH-1153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14520632#comment-14520632 ]
Phil Steitz commented on MATH-1153: ----------------------------------- See my comment above on the testNextInversionDeviate failure. I remain +1 for just dropping the test, as it is just a test of the default inversion-based sampling. There is no reason to expect that it will succeed for non-inversion based samplers. If there are no objections, I will drop it. If we really want to retain it, we should create a dummy distribution that will *always* use inversion-based sampling and replace the Beta instance with that (or come up with a better test somehow). I am not sure I understand your comments, Thomas, about "consuming more randomness" for other distributions. What tests, exactly would fail and why? The failing test is from the RandomDataGenerator and it is designed just to test the default inversion-based sampler that distributions that do not supply a custom sampler use. It was implemented (stupidly, in retrospect) using a Beta distribution when at the time that distribution did not override the default. Given the current code structure (with samplers moved to the dist package) it would probably also be better to move this test to AbstractRealDistributionTest if we decide to rectify and retain it. > 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: 4.0 > > Attachments: ChengBetaSampler.java, 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 > simple 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 > parameters. Communications of the ACM, 21, 317–322. -- This message was sent by Atlassian JIRA (v6.3.4#6332)