Reference / binference.samplers.MeanFieldVB
binference.samplers.MeanFieldVB¶
- class binference.samplers.MeanFieldVB(model, *, tol=1e-09, max_iter=10000, rng=None, progress=False)[source]¶
Mean-field variational Bayes: \(q(\rho)\prod_i q(z_i)\).
Coordinate ascent alternates \(q(z_i) \propto L_{ik}\exp E_q[\log\rho_k]\) and the conjugate update of \(q(\rho)\) (e.g. a Dirichlet). This is the algorithm of RAIL’s
VarInfStackSummarizer. It is fast but under- estimates posterior widths, severely so when per-object PDFs are broad compared with the bins (it ignores the correlation between labels and the population). Results are always flaggedapproximate=Trueand emit anApproximationWarning; prefer NUTS for error bars.With a selection function on fractions, the expected number of missed objects is plugged in at the current mean (an additional approximation).
No evidence lower bound is computed (with selection the plug-in update does not ascend one): iterations stop when the largest change of the mean is below
toltimes its largest value.- Parameters:
- modelPopulationModel
Must use a conjugate prior.
- tolfloat
Relative tolerance on the change of the mean.
- max_iterint
Maximum number of coordinate-ascent iterations.
- rngint, numpy.random.Generator, or None
For the draws from the variational posterior.
- progressbool
Accepted for a common signature; unused.
Methods
__init__(model, *[, tol, max_iter, rng, ...])fit()Run coordinate ascent; returns
(state, n_iter, converged).run([n_samples])Fit and return
n_samplesindependent draws from the variational posterior.unsupported(model)Why the engine cannot run on
model, orNonewhen it can.Attributes
approximatejointwhether the engine infers a selection from injections or a tallied response jointly (DECISIONS #30, #80, #81)
markovwhether its draws are Markov chains, described by R-hat and ESS
name