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.

__init__(prior, bins)[source]

Methods

__init__(prior, bins)

forward(x)

Map unconstrained x to logits / log-rates eta (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)

unbounded_density()

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

conjugate

has_centering

whether it has partial non-centring weights (with_centering; the logistic family)

has_density

kind

pseudocounts

counts its mode adds to the data's, alpha - 1 (Dirichlet) or a - 1 (GammaRates), as in EM's M-step; None for other priors

dim

forward(x)[source]

Map unconstrained x to logits / log-rates eta (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_eta is the gradient of the log-likelihood with respect to eta; the returned gradient is d/dx [log prior(x) + loglike].

Parameters:
xndarray (dim,)

Unconstrained point.

cacheobject

The cache forward() returned for x.

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) or a - 1 (GammaRates), as in EM’s M-step; None for other priors

unbounded_density()[source]

Whether the density of the fractions (or rates) is unbounded at the boundary.

Then its mode can lie on the boundary (components exactly zero), and NUTS meets very long tails in log space for components without data.