Class RejectionInversionZipfSampler

java.lang.Object
org.apache.commons.rng.sampling.distribution.SamplerBase
org.apache.commons.rng.sampling.distribution.RejectionInversionZipfSampler
All Implemented Interfaces:
DiscreteSampler

public class RejectionInversionZipfSampler
extends SamplerBase
implements DiscreteSampler
Implementation of the Zipf distribution.

Sampling uses UniformRandomProvider.nextDouble().

Since:
1.0
  • Constructor Summary

    Constructors 
    Constructor Description
    RejectionInversionZipfSampler​(UniformRandomProvider rng, int numberOfElements, double exponent)  
  • Method Summary

    Modifier and Type Method Description
    int sample()
    Rejection inversion sampling method for a discrete, bounded Zipf distribution that is based on the method described in Wolfgang Hörmann and Gerhard Derflinger.
    java.lang.String toString()

    Methods inherited from class org.apache.commons.rng.sampling.distribution.SamplerBase

    nextDouble, nextInt, nextInt, nextLong

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RejectionInversionZipfSampler

      public RejectionInversionZipfSampler​(UniformRandomProvider rng, int numberOfElements, double exponent)
      Parameters:
      rng - Generator of uniformly distributed random numbers.
      numberOfElements - Number of elements.
      exponent - Exponent.
      Throws:
      java.lang.IllegalArgumentException - if numberOfElements <= 0 or exponent <= 0.
  • Method Details

    • sample

      public int sample()
      Rejection inversion sampling method for a discrete, bounded Zipf distribution that is based on the method described in
      Wolfgang Hörmann and Gerhard Derflinger. "Rejection-inversion to generate variates from monotone discrete distributions",
      ACM Transactions on Modeling and Computer Simulation (TOMACS) 6.3 (1996): 169-184.
      Specified by:
      sample in interface DiscreteSampler
      Returns:
      a sample.
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class SamplerBase