Reference / binference.validation.exact_posterior

binference.validation.exact_posterior

binference.validation.exact_posterior(model, prior=None, n_grid=200, max_elements=4194304)[source]

Quadrature posterior of the fractions for K = 2 or K = 3 bins.

Works for priors with a closed-form simplex density (Dirichlet family). Selection effects are included. The fractions are stick-broken, \(\rho = (x, (1-x)y, (1-x)(1-y))\), each stick coordinate substituted as \((1-\cos\pi s)/2\) and integrated by Gauss-Legendre with n_grid nodes, which places nodes densely at the boundary and handles the integrable singularities of concentrations below one (audit G-3). With the default n_grid, means of a known Dirichlet posterior are exact to 0.01 posterior SD for concentrations down to 0.2, and tail probabilities to 0.005 for concentrations of 0.5 and above (at 0.2 the mass below a 6e-9 quantile is 22% off). max_elements bounds the size of the (objects x nodes) blocks evaluated at once (audit G-5).

Parameters:
modelPopulationModel, Likelihoods or array_like (N, K)

The model, or likelihoods to build one from with prior.

priorPopulationPrior, optional

Population prior; None gives Dirichlet(1.0).

n_gridint, optional

Gauss-Legendre nodes per stick coordinate.

max_elementsint, optional

Largest block of objects times nodes evaluated at once.