Reference / binference.priors.Dirichlet
binference.priors.Dirichlet¶
- class binference.priors.Dirichlet(alpha=1.0)[source]¶
Dirichlet prior \(\rho \sim \mathrm{Dir}(\alpha)\) on bin fractions.
The default prior of binference (
alpha=1, uniform on the simplex).- Parameters:
- alphafloat, array_like (K,), or “reference”
Concentration parameters (strictly positive).
"reference"usesalpha = 1/K(Berger, Bernardo & Sun 2015), which avoids swamping sparse problems with many bins.
Notes
A symmetric
alphaover bins of unequal volume is not consistent under merging bins;from_base_measure()makesalphaproportional to a base measure (flat in the measure coordinate by default) instead.Methods
__init__([alpha])bind(bins)describe(bins[, counts])The prior as a one-node tree, drawn as text (see
DirichletTree.describe()).from_base_measure([concentration, base])alpha_k = concentration * B_k, withBthe normalised bin masses ofbase.from_counts(counts[, strength, base])Prior from a reference sample:
alpha = base + strength * counts.reference([K])Reference prior
alpha = 1/K.resolve_alpha(bins)Attributes
kind"fractions"(a distribution on the simplex) or"rates"- describe(bins, counts=None)[source]¶
The prior as a one-node tree, drawn as text (see
DirichletTree.describe()).- Parameters:
- binsBins
The bins it is drawn on.
- countsarray_like (K,), optional
Counts per bin; the drawing then shows the posterior given them.
- classmethod from_base_measure(concentration=1.0, base='flat')[source]¶
alpha_k = concentration * B_k, withBthe normalised bin masses ofbase.baseis aDensity(or anythingDensity.coerceaccepts; an array is read as masses per bin). The default is flat in the measure coordinate, proportional to bin volumes on linear bins.- Parameters:
- concentrationfloat, optional
Total concentration, spread over the bins by the base measure.
- baseDensity, str, callable or array_like, optional
Base measure whose bin masses shape
alpha.
- classmethod from_counts(counts, strength=1.0, base=1.0)[source]¶
Prior from a reference sample:
alpha = base + strength * counts.strength < 1down-weights a reference sample that may not be fully representative (for a coherent model of an unrepresentative reference use a reference-centredLogisticNormalorLogisticRandomWalkwithmean=log(reference)).- Parameters:
- countsarray_like (K,)
Counts of the reference sample in each bin.
- strengthfloat, optional
Weight of the reference counts in
alpha.- basefloat, optional
Concentration added to every bin.