[
https://issues.apache.org/jira/browse/MATH-1220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14525985#comment-14525985
]
Thomas Neidhart commented on MATH-1220:
---------------------------------------
I am not so sure that rejection inversion method is generally better than yours.
Before applying the patch, I did some tests with this method too (using another
implementation that I found here:
http://www.nr.com/forum/showthread.php?t=1396, btw go also uses this method by
default: https://golang.org/src/math/rand/zipf.go), but I found that your
version seems to be faster for exponents > 1.
The rejection inversion method draws less random variables which kept me
undecided, but I wanted to value your contribution.
> More efficient sample() method for ZipfDistribution
> ---------------------------------------------------
>
> Key: MATH-1220
> URL: https://issues.apache.org/jira/browse/MATH-1220
> Project: Commons Math
> Issue Type: Improvement
> Reporter: Otmar Ertl
> Fix For: 4.0, 3.6
>
> Attachments: patch_v1, patch_v2
>
>
> Currently, sampling from a ZipfDistribution is very inefficient. Random
> values are generated by inverting the CDF. However, the current
> implementation uses O(N) power function evaluations to calculate the CDF for
> some point. (Here N is the number of points of the Zipf distribution.) I
> propose to use rejection sampling instead, which allows the generation of a
> single random value in constant time.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)