[
https://issues.apache.org/jira/browse/RNG-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16284697#comment-16284697
]
Gilles commented on RNG-37:
---------------------------
bq. keeps only 7 bits out of the 32
Sorry, this is incorrect: the value returned by {{nextInt()}} serves as a
multiplier, so all 32 are used.
So, for a source that generate 64-bits at a time, "only" 32-bits are wasted;
the question is then whether the additional (branching) logic for reusing those
bits would not completely offset the gain of generating one value in place of
two.
I did some trial, and it seems that the gain is indeed insignificant.
A different issue is that the code seems to copy statements that generate
{{float}} values in the [reference
implementation|http://www.jstatsoft.org/article/view/v005i08/ziggurat.pdf].
In the Java port, the hard-coded values that seems to have less precision than
they should (since {{double}} values are generated here). E.g. is a statement
such as
{code}
uni = 0.5 + nextInt() * 0.2328306e-9;
{code}
not going to miss {{double}} values close to 1?
> Ziggurat algorithm
> ------------------
>
> Key: RNG-37
> URL: https://issues.apache.org/jira/browse/RNG-37
> Project: Commons RNG
> Issue Type: Wish
> Reporter: Gilles
> Priority: Minor
>
> Fast algorithm for sampling a Gaussian distribution:
> https://en.wikipedia.org/wiki/Ziggurat_algorithm
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)