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
private static final class DirichletSampler.SymmetricDirichletSampler extends DirichletSampler
Sample from a symmetric Dirichlet distribution with the same concentration parameter for each category.
-
-
Field Summary
Fields Modifier and Type Field Description private int
k
Number of categories.private SharedStateContinuousSampler
sampler
Sampler for the categories.
-
Constructor Summary
Constructors Constructor Description SymmetricDirichletSampler(UniformRandomProvider rng, int k, SharedStateContinuousSampler sampler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
getK()
Gets the number of categories.protected double
nextGamma(int i)
Create a gamma sample for the given category.DirichletSampler.SymmetricDirichletSampler
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.-
Methods inherited from class org.apache.commons.rng.sampling.distribution.DirichletSampler
of, sample, symmetric, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.commons.rng.sampling.ObjectSampler
samples, samples
-
-
-
-
Field Detail
-
k
private final int k
Number of categories.
-
sampler
private final SharedStateContinuousSampler sampler
Sampler for the categories.
-
-
Constructor Detail
-
SymmetricDirichletSampler
SymmetricDirichletSampler(UniformRandomProvider rng, int k, SharedStateContinuousSampler sampler)
- Parameters:
rng
- Generator of uniformly distributed random numbers.k
- Number of categories.sampler
- Sampler for the categories.
-
-
Method Detail
-
getK
protected int getK()
Description copied from class:DirichletSampler
Gets the number of categories.- Specified by:
getK
in classDirichletSampler
- Returns:
- k
-
nextGamma
protected double nextGamma(int i)
Description copied from class:DirichletSampler
Create a gamma sample for the given category.- Specified by:
nextGamma
in classDirichletSampler
- Parameters:
i
- Category.- Returns:
- the sample
-
withUniformRandomProvider
public DirichletSampler.SymmetricDirichletSampler withUniformRandomProvider(UniformRandomProvider rng)
Description copied from class:DirichletSampler
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:
withUniformRandomProvider
in interfaceSharedStateSampler<SharedStateObjectSampler<double[]>>
- Specified by:
withUniformRandomProvider
in classDirichletSampler
- Parameters:
rng
- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-
-