commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergei Lebedev (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (MATH-1153) Sampling from a 'BetaDistribution' is slow
Date Thu, 29 Jan 2015 15:49:34 GMT

    [ https://issues.apache.org/jira/browse/MATH-1153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14297031#comment-14297031
] 

Sergei Lebedev edited comment on MATH-1153 at 1/29/15 3:48 PM:
---------------------------------------------------------------

I think KS-test failures might be related to the incorrect P-value calculation in the presence
of ties (reported in MATH-1197). Ties are common for Beta distribution with extreme parameter
values, e. g.
{code}
> sum(rbeta(1024, 100, 0.01) == 1)
[1] 738
{code}

I've attached a minor improvement to the original ChengBetaSampler which uses logs where appropriate.



was (Author: lebedev):
I think KS-test failures might be related to the incorrect P-value calculation in the presence
of ties (reported in MATH-1197).  

I've attached a minor improvement to the original ChengBetaSampler which uses logs where appropriate.


> 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)

Mime
View raw message