Uploaded image for project: 'Commons RNG'
  1. Commons RNG
  2. RNG-165

RejectionInversionZipfSampler should allow exponent of zero

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.4
    • 1.5
    • sampling
    • None

    Description

      The Zipf distribution is defined when the exponent is zero.

      Zipf (Wikipedia)
      Zipfian distribution (scipy)

      Currently the RejectionInversionZipfSampler does not allow the exponent to be zero.

      The PMF is:

      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
      

      In the case of a zero exponent the generalised harmonic number reduces to n and the PMF is:

      pmf(x) = 1 / n
      

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            aherbert Alex Herbert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 50m
                50m