public class ChengBetaSampler extends SamplerBase implements SharedStateContinuousSampler
Uses Cheng's algorithms for beta distribution sampling:
R. C. H. Cheng, "Generating beta variates with nonintegral shape parameters", Communications of the ACM, 21, 317-322, 1978.
Sampling uses UniformRandomProvider.nextDouble().
| Constructor and Description |
|---|
ChengBetaSampler(UniformRandomProvider rng,
double alpha,
double beta)
Creates a sampler instance.
|
| Modifier and Type | Method and Description |
|---|---|
static SharedStateContinuousSampler |
of(UniformRandomProvider rng,
double alpha,
double beta)
Creates a new beta distribution sampler.
|
double |
sample()
Creates a
double sample. |
String |
toString() |
SharedStateContinuousSampler |
withUniformRandomProvider(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.
|
nextDouble, nextInt, nextInt, nextLongclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitsamples, samplespublic ChengBetaSampler(UniformRandomProvider rng, double alpha, double beta)
rng - Generator of uniformly distributed random numbers.alpha - Distribution first shape parameter.beta - Distribution second shape parameter.IllegalArgumentException - if alpha <= 0 or beta <= 0public double sample()
double sample.sample in interface ContinuousSamplerpublic String toString()
toString in class SamplerBasepublic SharedStateContinuousSampler withUniformRandomProvider(UniformRandomProvider rng)
withUniformRandomProvider in interface SharedStateSampler<SharedStateContinuousSampler>rng - Generator of uniformly distributed random numbers.public static SharedStateContinuousSampler of(UniformRandomProvider rng, double alpha, double beta)
rng - Generator of uniformly distributed random numbers.alpha - Distribution first shape parameter.beta - Distribution second shape parameter.IllegalArgumentException - if alpha <= 0 or beta <= 0Copyright © 2016–2022 The Apache Software Foundation. All rights reserved.