You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex Herbert (Jira)" <ji...@apache.org> on 2021/10/01 18:34:00 UTC

[jira] [Commented] (RNG-165) RejectionInversionZipfSampler should allow exponent of zero

    [ https://issues.apache.org/jira/browse/RNG-165?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17423397#comment-17423397 ] 

Alex Herbert commented on RNG-165:
----------------------------------

Fixed in commit:

a6ca79b76028c95a71fe63945b9092f2039c8106

A zero exponent will delegate sampling to the DiscreteUniformSampler.

 

> RejectionInversionZipfSampler should allow exponent of zero
> -----------------------------------------------------------
>
>                 Key: RNG-165
>                 URL: https://issues.apache.org/jira/browse/RNG-165
>             Project: Commons RNG
>          Issue Type: Bug
>          Components: sampling
>    Affects Versions: 1.4
>            Reporter: Alex Herbert
>            Priority: Minor
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> The Zipf distribution is defined when the exponent is zero.
> [Zipf (Wikipedia)|https://en.wikipedia.org/wiki/Zipf%27s_law]
>  [Zipfian distribution (scipy)|https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.zipfian.html]
> Currently the RejectionInversionZipfSampler does not allow the exponent to be zero.
> The PMF is:
> {noformat}
> pmf(x) = 1/x^s / Hn,s
> x in [1, n]
> n = number of elements
> s = exponent
> Hn,s is the Nth generalised harmonic number
> {noformat}
> In the case of a zero exponent the generalised harmonic number reduces to n and the PMF is:
> {noformat}
> pmf(x) = 1 / n
> {noformat}
> The distribution is a discrete uniform distribution.
> I suggest extracting the sampling logic for the RejectionInversionZipfSampler into a nested class to be used as a delegate from the outer class's sample method. In the special case of a zero exponent the delegate can be replaced with a DiscreteUniformSampler.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)