[
https://issues.apache.org/jira/browse/RNG-51?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16623685#comment-16623685
]
ASF GitHub Bot commented on RNG-51:
-----------------------------------
GitHub user aherbert opened a pull request:
https://github.com/apache/commons-rng/pull/10
Improvement rng 51
RNG-51: Added a PoissonSamplerCache that exploits the fact that the state
of the LargeMeanPoissonSampler is constant for all means in the range `n <=
mean < n+1` where `n` is the floor of the mean.
A JMH speed test has been added to show the expected performance benefit
for single-use Poisson samples.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/aherbert/commons-rng improvement-RNG-51
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/commons-rng/pull/10.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #10
----
commit fa38dea519c49640c485299d47516f9fb3d51fde
Author: Alex Herbert <a.herbert@...>
Date: 2018-09-20T22:17:36Z
RNG-51: Added a PoissonSamplerCache for the large mean algorithm
commit db751b911b56fecff1bce1ce33320e4308158c6a
Author: Alex Herbert <a.herbert@...>
Date: 2018-09-20T23:56:19Z
RNG-51: Changed representation of LargeMeanPoissonSampler state
commit b7723280bcaeb0ce9700d47cfc96b925d8a607cb
Author: Alex Herbert <a.herbert@...>
Date: 2018-09-21T00:03:19Z
RNG-51: The LargeMeanPoissonSamplerState should be final
commit 120d275ed34b4d5b9a0729e788382ffa39d050ce
Author: aherbert <a.herbert@...>
Date: 2018-09-21T13:52:16Z
RNG-51: Added JMH performance test
commit 21927cbc3005e5a7f3a45c527597a5733d735b4d
Author: aherbert <a.herbert@...>
Date: 2018-09-21T13:55:37Z
Merge branch 'master' of git://github.com/apache/commons-rng into
improvement-RNG-51
commit ef5470249ca404a28b7106d1a16ae768ad224cda
Author: aherbert <a.herbert@...>
Date: 2018-09-21T14:11:45Z
RNG-51: Updated for 1.2-SNAPSHOT
----
> 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)