Class DirichletSampler.SymmetricDirichletSampler
java.lang.Object
org.apache.commons.rng.sampling.distribution.DirichletSampler
org.apache.commons.rng.sampling.distribution.DirichletSampler.SymmetricDirichletSampler
- All Implemented Interfaces:
ObjectSampler<double[]>,SharedStateObjectSampler<double[]>,SharedStateSampler<SharedStateObjectSampler<double[]>>
- Enclosing class:
DirichletSampler
Sample from a symmetric Dirichlet distribution with the same concentration parameter
for each category.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intNumber of categories.private final SharedStateContinuousSamplerSampler for the categories. -
Constructor Summary
ConstructorsConstructorDescriptionSymmetricDirichletSampler(UniformRandomProvider rng, int k, SharedStateContinuousSampler sampler) -
Method Summary
Modifier and TypeMethodDescriptionprotected intgetK()Gets the number of categories.protected doublenextGamma(int i) Create a gamma sample for the given category.Create 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 org.apache.commons.rng.sampling.distribution.DirichletSampler
of, sample, symmetric, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.rng.sampling.ObjectSampler
samples, samples
-
Field Details
-
k
private final int kNumber of categories. -
sampler
Sampler for the categories.
-
-
Constructor Details
-
Method Details
-
getK
protected int getK()Description copied from class:DirichletSamplerGets the number of categories.- Specified by:
getKin classDirichletSampler- Returns:
- k
-
nextGamma
protected double nextGamma(int i) Description copied from class:DirichletSamplerCreate a gamma sample for the given category.- Specified by:
nextGammain classDirichletSampler- Parameters:
i- Category.- Returns:
- the sample
-
withUniformRandomProvider
public DirichletSampler.SymmetricDirichletSampler withUniformRandomProvider(UniformRandomProvider rng) Description copied from class:DirichletSamplerCreate 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[]>>- Specified by:
withUniformRandomProviderin classDirichletSampler- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-