[
https://issues.apache.org/jira/browse/MATH-1220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14514835#comment-14514835
]
Thomas Neidhart commented on MATH-1220:
---------------------------------------
Yes, I was referring to the pre-computated CDF table. I understand that for
large N this will not be as efficient as your rejection sampling approach. Is
the O(1) runtime complexity of your approach also guaranteed for small N?
Otherwise the proposed mixture could be a good solution.
Another thing: as far as I understand, the rejection sampling method could be
potentially applied to different distributions. Do you see a way to generalize
it so that it could be re-used for others too?
> 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
> Attachments: patch_v1
>
>
> 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)