Class RejectionInversionZipfSampler

    • Method Detail

      • 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.
      • of

        public static SharedStateDiscreteSampler of​(UniformRandomProvider rng,
                                                    int numberOfElements,
                                                    double exponent)
        Creates a new Zipf distribution sampler.

        Note when exponent = 0 the Zipf distribution reduces to a discrete uniform distribution over the interval [1, n] with n the number of elements.

        Parameters:
        rng - Generator of uniformly distributed random numbers.
        numberOfElements - Number of elements.
        exponent - Exponent.
        Returns:
        the sampler
        Throws:
        IllegalArgumentException - if numberOfElements <= 0 or exponent < 0.
        Since:
        1.3