Update ziggurat sampler using result of the performance tests
authoraherbert <aherbert@apache.org>
Thu, 26 Aug 2021 17:05:04 +0000 (18:05 +0100)
committeraherbert <aherbert@apache.org>
Thu, 26 Aug 2021 17:08:21 +0000 (18:08 +0100)
commitd8fdc7d8a8c3701643181fc7b65dc6e17931f9eb
tree6a31491f26c6cd83452291b1db529eb767c08092
parent958245a7e75c5b1a6488d008bd739844097c972f
Update ziggurat sampler using result of the performance tests

Use a single method to interpolate x and y. This avoids a subtraction in
the interpolation of y.

Avoid recursion in the exponential sampler.

Use shifts to generate unsigned longs. This favours the upper bits of
the uniform deviate.

Each change is either mute or may have a marginal benefit depending on
the platform. Together the sampler should be consistently performant
across JDKs and platforms.

Update tests that manipulate the output from the exponential sampler:
stable sampler test
ziggurat sampler test
commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ZigguratSampler.java
commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/StableSamplerTest.java
commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ZigguratSamplerTest.java