Reference / binference.PointEstimate
binference.PointEstimate¶
- class binference.PointEstimate(model, value, *, method='map', x=None, log_posterior=nan, log_likelihood=nan, kkt_gap=nan, n_iter=0, converged=True, info=None)[source]¶
A MAP / maximum-likelihood estimate of the population.
- Attributes:
- value(K,) array
Fractions (or rates for rate models) at the optimum, a read-only copy; with a
Basis, the component weights (rhoandratesare per bin).- x(dim,) array or None
Unconstrained coordinates (when optimised there).
- kkt_gapfloat
Optimality certificate (zero at the exact optimum on the simplex).
- __init__(model, value, *, method='map', x=None, log_posterior=nan, log_likelihood=nan, kkt_gap=nan, n_iter=0, converged=True, info=None)[source]¶
Methods
__init__(model, value, *[, method, x, ...])assignment_probabilities([idx, n_draws, chunk])Posterior probability that each object lies in each bin, \(P(k_i = k \mid D)\).
assignment_probabilities_best([idx])assignment_probabilities()at the best fit,best.assignment_probabilities_loo([idx, n_draws, ...])Each object's posterior over bins under the population fitted without it, \(P(k_i = k \mid D_{-i})\): leave-one-out, for calibration checks.
check(*[, kkt_max, strict])Warn (or raise with
strict=True) when the optimiser did not converge, when the KKT gap (per object; seePopulationModel.kkt_gap()) exceedskkt_max, when sample likelihoods carry too much Monte Carlo noise, or when injections are too few where much of the population lies.density()Population density per unit bin volume at the optimum (see
PopulationResult.density()).laplace([n_samples, rng])Laplace approximation around the mode (see
binference.engines.Laplace).log_predictive(likelihoods, *[, n_draws, chunk])Log posterior-predictive density of new objects, \(\log E[L_i\cdot\rho]\).
log_predictive_best(likelihoods, **kwargs)log_predictive()at the best fit,best.plot(**kwargs)Plot the estimate (see
binference.plotting.plot_population()).plot_individual(i, **kwargs)Object
i's own likelihood against its hierarchical posterior (seebinference.plotting.plot_individual()).predict_proba(likelihoods, *[, n_draws, chunk])Posterior over bins for new objects under the inferred population.
predict_proba_best(likelihoods, **kwargs)predict_proba()at the best fit,best.prior_information_ratio([h])Efron's (2016) ratio of prior to data information, \(\mathrm{tr}(-H_\text{prior}) / \mathrm{tr}(-H_\text{data})\).
realized_counts(*[, n_draws, rng, full])Draws of the realised histogram of the observed objects' true bins.
realized_counts_best(**kwargs)realized_counts()at the best fit,best.sample_assignments([idx, n_draws, rng])Joint draws of the bin labels of objects
idx(all by default).sample_assignments_best([idx])sample_assignments()at the best fit,best.sample_values([idx, n_draws, rng, loglike, ...])Joint draws of the continuous true values of objects
idx.sample_values_best([idx])sample_values()at the best fit,best.Attributes
The best fit of a point estimate is itself.
data_supportObjects' worth of likelihood in each bin, \(\sum_i w_i L_{ik} / \sum_{k'} L_{ik'}\) with each object's likelihood normalised over the bins: below about one, a bin's fraction is set by the prior.
Rates at the optimum (per bin): for fractions \(\hat\Lambda\rho\) with \(\hat\Lambda = W / (S\cdot\rho)\) (
Nonewith a relative selection).Population fractions at the optimum (per bin).
The selected population at the estimate (see
PopulationResult.selected).The selection function of the fit (a point estimate is not saved, so it is always the model's).
Total rate at the optimum (see
rates).modelbasisbinskindmethodinfo- property best¶
The best fit of a point estimate is itself.
- check(*, kkt_max=0.0001, strict=False)[source]¶
Warn (or raise with
strict=True) when the optimiser did not converge, when the KKT gap (per object; seePopulationModel.kkt_gap()) exceedskkt_max, when sample likelihoods carry too much Monte Carlo noise, or when injections are too few where much of the population lies.Estimates found by L-BFGS in unconstrained coordinates have no KKT gap (NaN); for them the check is
converged(seetolofMAP).The default is ten times the round-off floor at which MAP stops. Returns the messages (empty if the estimate looks fine).
- Parameters:
- kkt_maxfloat, optional
Largest KKT gap that passes.
- strictbool, optional
Raise
DiagnosticsErrorinstead of warning.
- density()[source]¶
Population density per unit bin volume at the optimum (see
PopulationResult.density()).
- laplace(n_samples=4000, *, rng=None, **kwargs)[source]¶
Laplace approximation around the mode (see
binference.engines.Laplace).- Parameters:
- n_samplesint, optional
Draws of the Laplace approximation.
- rngint, Generator or None
Random number generator.
- **kwargs
Options of
Laplace.
- plot(**kwargs)[source]¶
Plot the estimate (see
binference.plotting.plot_population()).- Parameters:
- **kwargs
Passed to
binference.plotting.plot_population().
- property rates¶
Rates at the optimum (per bin): for fractions \(\hat\Lambda\rho\) with \(\hat\Lambda = W / (S\cdot\rho)\) (
Nonewith a relative selection).
- property rho¶
Population fractions at the optimum (per bin).
- property selected¶
The selected population at the estimate (see
PopulationResult.selected).
- property selection¶
The selection function of the fit (a point estimate is not saved, so it is always the model’s).