Class DirichletSampler
java.lang.Object
org.apache.commons.rng.sampling.distribution.DirichletSampler
- All Implemented Interfaces:
ObjectSampler<double[]>, SharedStateObjectSampler<double[]>, SharedStateSampler<SharedStateObjectSampler<double[]>>
Sampling from a Dirichlet
distribution.
Sampling uses:
- Since:
- 1.4
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract intgetK()Gets the number of categories.protected abstract doublenextGamma(int category) Create a gamma sample for the given category.static DirichletSamplerof(UniformRandomProvider rng, double... alpha) Creates a new Dirichlet distribution sampler.double[]sample()Create an object sample.static DirichletSamplersymmetric(UniformRandomProvider rng, int k, double alpha) Creates a new symmetric Dirichlet distribution sampler using the same concentration parameter for each category.toString()abstract DirichletSamplerCreate a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ObjectSampler
samples, samples
-
Method Details
-
toString
-
sample
Create an object sample.- Specified by:
samplein interfaceObjectSampler<double[]>- Returns:
- a sample.
-
getK
-
nextGamma
Create a gamma sample for the given category.- Parameters:
category- Category.- Returns:
- the sample
-
withUniformRandomProvider
Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.- Specified by:
withUniformRandomProviderin interfaceSharedStateSampler<SharedStateObjectSampler<double[]>>- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-
of
Creates a new Dirichlet distribution sampler.- Parameters:
rng- Generator of uniformly distributed random numbers.alpha- Concentration parameters.- Returns:
- the sampler
- Throws:
IllegalArgumentException- if the number of concentration parameters is less than 2; or if any concentration parameter is not strictly positive.
-
symmetric
Creates a new symmetric Dirichlet distribution sampler using the same concentration parameter for each category.- Parameters:
rng- Generator of uniformly distributed random numbers.k- Number of categories.alpha- Concentration parameter.- Returns:
- the sampler
- Throws:
IllegalArgumentException- if the number of categories is less than 2; or if the concentration parameter is not strictly positive.
-