Reference / binference.priors.BoundPrior
binference.priors.BoundPrior¶
- class binference.priors.BoundPrior(prior, bins)[source]¶
Numerical interface of a prior bound to specific bins (internal).
- Parameters:
- priorPopulationPrior
The prior.
- binsBins
The bins it is bound to.
Methods
__init__(prior, bins)forward(x)Map unconstrained
xto logits / log-rateseta(and a cache).grad_log_density(value)Gradient of
log_density()with respect to the fractions/rates.init_from_value(value)An unconstrained starting point near the given fractions or rates.
log_density(value)Log-density of fractions (on the simplex) or rates.
log_prior_and_grad(x, cache, value, d_eta)Prior log-density in
x-space and the total gradient.map_from_counts(counts[, exposure])posterior_sample(counts, rng[, exposure])sample(n, rng)Whether the density of the fractions (or rates) is unbounded at the boundary.
vb_expected_log(state)vb_mean(state)vb_sample(state, n, rng)vb_update(counts[, exposure])Attributes
conjugatewhether it has partial non-centring weights (
with_centering; the logistic family)has_densitykindcounts its mode adds to the data's,
alpha - 1(Dirichlet) ora - 1(GammaRates), as in EM's M-step;Nonefor other priorsdim- forward(x)[source]¶
Map unconstrained
xto logits / log-rateseta(and a cache).- Parameters:
- xndarray (dim,)
Unconstrained point.
- grad_log_density(value)[source]¶
Gradient of
log_density()with respect to the fractions/rates.Components with zero value are returned as zero (they are handled as active constraints by callers).
- Parameters:
- valuendarray (K,)
Fractions or rates.
- has_centering = False¶
whether it has partial non-centring weights (
with_centering; the logistic family)
- init_from_value(value)[source]¶
An unconstrained starting point near the given fractions or rates.
Exact for the Dirichlet family and rates; for the logistic priors a ridge-regularised fit that shrinks towards the prior mean.
- Parameters:
- valuendarray (K,)
Fractions or rates.
- log_density(value)[source]¶
Log-density of fractions (on the simplex) or rates.
- Parameters:
- valuendarray (…, K)
Fractions or rates.
- log_prior_and_grad(x, cache, value, d_eta)[source]¶
Prior log-density in
x-space and the total gradient.d_etais the gradient of the log-likelihood with respect toeta; the returned gradient isd/dx [log prior(x) + loglike].- Parameters:
- xndarray (dim,)
Unconstrained point.
- cacheobject
The cache
forward()returned forx.- valuendarray (K,)
Fractions or rates at
x.- d_etandarray (K,)
Gradient of the log-likelihood with respect to
eta.
- pseudocounts = None¶
counts its mode adds to the data’s,
alpha - 1(Dirichlet) ora - 1(GammaRates), as in EM’s M-step;Nonefor other priors