mixle.stats.bayes.symmetric_dirichlet moduleΒΆ
Symmetric Dirichlet distribution on probability vectors with a single shared concentration alpha.
Observations are length-n sequences/arrays of non-negative reals summing to one (points on the (n-1)-simplex), scored with one shared concentration parameter alpha. The log-density is
log f(x; alpha) = sum_k (alpha - 1)*log(x_k) + gammaln(n*alpha) - n*gammaln(alpha),
where n = len(x) is inferred from each observation.
This is a parameter prior (the conjugate Dirichlet prior used by
IntegerCategoricalDistribution when a symmetric prior is desired). It
is scored on probability vectors, not fit from data by EM. Ported from mixle.bstats.symdirichlet.
- class SymmetricDirichletDistribution(alpha, dim=None, name=None)[source]
Bases:
SequenceEncodableProbabilityDistributionSymmetric Dirichlet distribution with shared concentration alpha; the dimension is inferred from each observation (or fixed with dim for sampling).
- set_parameters(params)[source]
Set the shared concentration parameter alpha.
- Parameters:
params (float)
- Return type:
None
- density(x)[source]
Density at the probability vector x (exp of log_density).
- log_density(x)[source]
Log-density of the symmetric Dirichlet at the probability vector x.
- seq_log_density(x)[source]
Vectorized log-density at sequence-encoded (m, n) array of probability vectors.
- sampler(seed=None)[source]
Returns a SymmetricDirichletSampler for this distribution.
- Parameters:
seed (int | None)
- Return type:
SymmetricDirichletSampler
- estimator(pseudo_count=None)[source]
SymmetricDirichlet is a parameter prior and is not fit from data by EM.
- Parameters:
pseudo_count (float | None)
- Return type:
ParameterEstimator
- dist_to_encoder()[source]
Returns a SymmetricDirichletDataEncoder for encoding probability vectors.
- Return type:
SymmetricDirichletDataEncoder