DiscreteSampler, SharedStateDiscreteSampler, SharedStateSampler<SharedStateDiscreteSampler>public class RejectionInversionZipfSampler extends SamplerBase implements SharedStateDiscreteSampler
Sampling uses UniformRandomProvider.nextDouble().
| Constructor | Description |
|---|---|
RejectionInversionZipfSampler(org.apache.commons.rng.UniformRandomProvider rng,
int numberOfElements,
double exponent) |
| Modifier and Type | Method | Description |
|---|---|---|
static SharedStateDiscreteSampler |
of(org.apache.commons.rng.UniformRandomProvider rng,
int numberOfElements,
double exponent) |
Creates a new Zipf distribution sampler.
|
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() |
|
SharedStateDiscreteSampler |
withUniformRandomProvider(org.apache.commons.rng.UniformRandomProvider rng) |
Create a new instance of the sampler with the same underlying state using the given
uniform random provider as the source of randomness.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitnextDouble, nextInt, nextInt, nextLongpublic RejectionInversionZipfSampler(org.apache.commons.rng.UniformRandomProvider rng, int numberOfElements, double exponent)
rng - Generator of uniformly distributed random numbers.numberOfElements - Number of elements.exponent - Exponent.java.lang.IllegalArgumentException - if numberOfElements <= 0
or exponent <= 0.public int sample()
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.
sample in interface DiscreteSamplerpublic java.lang.String toString()
toString in class SamplerBasepublic SharedStateDiscreteSampler withUniformRandomProvider(org.apache.commons.rng.UniformRandomProvider rng)
withUniformRandomProvider in interface SharedStateSampler<SharedStateDiscreteSampler>rng - Generator of uniformly distributed random numbers.public static SharedStateDiscreteSampler of(org.apache.commons.rng.UniformRandomProvider rng, int numberOfElements, double exponent)
rng - Generator of uniformly distributed random numbers.numberOfElements - Number of elements.exponent - Exponent.java.lang.IllegalArgumentException - if numberOfElements <= 0 or
exponent <= 0.Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.