calculate_likelihood_statistic
- zdm.optical_numerics.calculate_likelihood_statistic(NFRB, AppMags, AppMagPriors, ObsMags, ObsPosteriors, PUobs, PUprior, plotfile=None, POxcut=None)[source]
Compute the total log-likelihood of the observed PATH posteriors given the model prior.
For each FRB, evaluates log10(Σ P(O_i|x) / rescale + P_U_prior), where the rescale factor accounts for PATH’s internal renormalisation of posteriors relative to the model prior. Summing over all FRBs gives the total log-likelihood returned to the caller.
- Parameters:
NFRB (int) – Number of FRBs to sum over.
AppMags (np.ndarray, shape (NMAG,)) – Apparent magnitude grid used to compute the model prior (not used directly in this function, but kept for API consistency with
calculate_ks_statistic).AppMagPriors (list of np.ndarray, length NFRB) – Model prior p(m_r | DM_EG) on the
AppMagsgrid, one array per FRB.ObsMags (list of np.ndarray, length NFRB) – Observed r-band magnitudes of PATH candidate host galaxies, one array per FRB (length NCAND varies by FRB).
ObsPosteriors (list of np.ndarray, length NFRB) – PATH posterior P(O_i|x) for each candidate, one array per FRB.
PUobs (list of float, length NFRB) – PATH posterior P(U|x) — probability that the true host is undetected — for each FRB, as returned by PATH after renormalisation.
PUprior (list of float, length NFRB) – Model prior P_U for each FRB, as estimated by
wrapper.estimate_unseen_prior().plotfile (str or None, optional) – If provided, save a diagnostic plot comparing prior and posterior magnitude distributions to this file path. Defaults to None.
POxcut (float or None, optional) – If not None, restrict the statistic to FRBs whose maximum P(O|x) exceeds this threshold (simulates requiring a confident host ID). Defaults to None.
- Returns:
stat – Total log10-likelihood summed over all NFRB FRBs. Larger values indicate a better fit. Multiply by -1 for use as a minimisation objective.
- Return type: