ContinuousSampler
, SharedStateContinuousSampler
, SharedStateSampler<SharedStateContinuousSampler>
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 | Description |
---|---|
ChengBetaSampler(org.apache.commons.rng.UniformRandomProvider rng,
double alpha,
double beta) |
Creates a sampler instance.
|
Modifier and Type | Method | Description |
---|---|---|
static SharedStateContinuousSampler |
of(org.apache.commons.rng.UniformRandomProvider rng,
double alpha,
double beta) |
Creates a new beta distribution sampler.
|
double |
sample() |
Creates a sample.
|
java.lang.String |
toString() |
|
SharedStateContinuousSampler |
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, wait
nextDouble, nextInt, nextInt, nextLong
public ChengBetaSampler(org.apache.commons.rng.UniformRandomProvider rng, double alpha, double beta)
rng
- Generator of uniformly distributed random numbers.alpha
- Distribution first shape parameter.beta
- Distribution second shape parameter.java.lang.IllegalArgumentException
- if alpha <= 0
or beta <= 0
public double sample()
sample
in interface ContinuousSampler
public java.lang.String toString()
toString
in class SamplerBase
public SharedStateContinuousSampler withUniformRandomProvider(org.apache.commons.rng.UniformRandomProvider rng)
withUniformRandomProvider
in interface SharedStateSampler<SharedStateContinuousSampler>
rng
- Generator of uniformly distributed random numbers.public static SharedStateContinuousSampler of(org.apache.commons.rng.UniformRandomProvider rng, double alpha, double beta)
rng
- Generator of uniformly distributed random numbers.alpha
- Distribution first shape parameter.beta
- Distribution second shape parameter.java.lang.IllegalArgumentException
- if alpha <= 0
or beta <= 0
Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.