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/09/29 15:27:00 UTC

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

Alex Herbert created RNG-165:
--------------------------------

             Summary: 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


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)