commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (RNG-51) PoissonSampler single use speed improvements using a cache
Date Mon, 17 Sep 2018 23:12:00 GMT

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

Gilles edited comment on RNG-51 at 9/17/18 11:11 PM:
-----------------------------------------------------

{quote}I was waiting for a 1.2 branch to appear
{quote}
Current "master" is [1.2 (snapshot)|https://git1-us-west.apache.org/repos/asf?p=commons-rng.git;a=blob;f=pom.xml;h=27163dd00f27d4076cbc6e61e42085069adc062b;hb=f5599152a715a987f36d7606ba3a967b7d297501]
since the release of v1.1.

bq. a lot of extra code for a second constructor [...] I'll try and do this this week.

Great. This would warrant a v1.2 release.


was (Author: erans):
{quote}I was waiting for a 1.2 branch to appear
{quote}
Current "master" is [1.2 (snapshot)|https://git1-us-west.apache.org/repos/asf?p=commons-rng.git;a=blob;f=pom.xml;h=27163dd00f27d4076cbc6e61e42085069adc062b;hb=f5599152a715a987f36d7606ba3a967b7d297501]
since the release of v1.1.

 bq. a lot of extra code for a second constructor [...] I'll try and do this this week.

Great. This would warrant a v1.2 release.

> PoissonSampler single use speed improvements using a cache
> ----------------------------------------------------------
>
>                 Key: RNG-51
>                 URL: https://issues.apache.org/jira/browse/RNG-51
>             Project: Commons RNG
>          Issue Type: Improvement
>    Affects Versions: 1.1
>            Reporter: Alex D Herbert
>            Priority: Minor
>              Labels: performance
>
> This improvement is a follow on from RNG-50.
> That improved the PoissonSampler by splitting it into two samplers for the different
algorithms (SmallMeanPoissonSampler and LargeMeanPoissonSampler) and moving initialisation
computations from the sample method into the constructor. This improved the speed of repeat
use of the same sampler by up to 3-fold. It does not effect single-use of a sampler.
> In the case of the LargeMeanPoissonSampler the initialisation 'state' computed within
the constructor involves 2 Math.log, 2 Math.exp, 2 Math.sqrt and 1 logFactorial computations.
If the sampler is used to generate only 1 sample then the cost of computing the state is a
significant portion of the sample time.
> However the state is not unique to the mean of the Poisson distribution but the {{(int)Math.floor(mean)}}.
This means the initialisation state can be shared and reused by PoissonSamplers with different
means.
> This was demonstrated using a JMH benchmark speed test comparing the standard PoissonSampler
verses a PoissonSamplerCache that can store the initialisation state of the PoissonSampler.
> For single-use Poisson samples with a mean within a known range the cache can provide
1.3 to 2x speed-up as initialisation state can be reused.
> The original benchmark was performed using Version 1.0. The Version 1.1. samplers use
a new faster Gaussian sampler internally. So the benchmark should be repeated for Version
1.1.
> The test project containing the V1.0 JMH benchmark is here: [poisson-sampler-test-code|https://github.com/aherbert/poisson-sampler-test-code]
> I propose to update this project to reference V1.1 of Commons RNG and repeat the test
of the PoissonSamplerCache. Results will be posted when available. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message