From c34fb1082851be53f12b25ec18597ee85e6da8ac Mon Sep 17 00:00:00 2001 From: alicjapolanska Date: Fri, 27 Sep 2024 15:17:54 +0100 Subject: [PATCH] Update logged info and diagnostics. --- examples/gaussian_nondiagcov.py | 57 ++++++++++----------------------- 1 file changed, 17 insertions(+), 40 deletions(-) diff --git a/examples/gaussian_nondiagcov.py b/examples/gaussian_nondiagcov.py index febd36e..756b5c7 100644 --- a/examples/gaussian_nondiagcov.py +++ b/examples/gaussian_nondiagcov.py @@ -198,56 +198,33 @@ def run_example( if i_realisation == 0: ln_evidence_analytic = ln_analytic_evidence(ndim, cov) - # ====================================================================== - # Display evidence computation results. - # ====================================================================== hm.logs.info_log("---------------------------------") + hm.logs.info_log("The inverse evidence in log space is:") hm.logs.info_log( - "Evidence: analytic = {}, estimated = {}".format( - np.exp(ln_evidence_analytic), np.exp(ln_evidence) + "ln_inv_evidence = {} +/- {}".format( + ev.ln_evidence_inv, err_ln_inv_evidence ) ) hm.logs.info_log( - "Evidence: std = {}, std / estimate = {}".format( - np.exp(ln_evidence_std), np.exp(ln_evidence_std - ln_evidence) + "ln evidence = {} +/- {} {}".format( + -ev.ln_evidence_inv, -err_ln_inv_evidence[1], -err_ln_inv_evidence[0] ) ) - diff = np.log(np.abs(np.exp(ln_evidence_analytic) - np.exp(ln_evidence))) + hm.logs.info_log("Analytic ln evidence is ", ln_evidence_analytic) + delta = -ln_evidence_analytic - ev.ln_evidence_inv hm.logs.info_log( - "Evidence: |analytic - estimate| / estimate = {}".format( - np.exp(diff - ln_evidence) - ) - ) - # ====================================================================== - # Display inverse evidence computation results. - # ====================================================================== - hm.logs.debug_log("---------------------------------") - hm.logs.debug_log( - "Inv Evidence: analytic = {}, estimate = {}".format( - np.exp(-ln_evidence_analytic), ev.evidence_inv - ) - ) - hm.logs.debug_log( - "Inv Evidence: std = {}, std / estimate = {}".format( - np.sqrt(ev.evidence_inv_var), - np.sqrt(ev.evidence_inv_var) / ev.evidence_inv, - ) - ) - hm.logs.debug_log( - "Inv Evidence: kurtosis = {}, sqrt( 2 / ( n_eff - 1 ) ) = {}".format( - ev.kurtosis, np.sqrt(2.0 / (ev.n_eff - 1)) - ) + "Difference between analytic and harmonic is ", + delta, + "+/-", + err_ln_inv_evidence[0], + err_ln_inv_evidence[1], ) + + hm.logs.debug_log("kurtosis = {}".format(ev.kurtosis), " Aim for ~3.") + check = np.exp(0.5 * ev.ln_evidence_inv_var_var - ev.ln_evidence_inv_var) + hm.logs.debug_log("sqrt( var(var) ) / var = = {}".format(check)) hm.logs.debug_log( - "Inv Evidence: sqrt( var(var) ) / var = {}".format( - np.sqrt(ev.evidence_inv_var_var) / ev.evidence_inv_var - ) - ) - hm.logs.info_log( - "Inv Evidence: |analytic - estimate| / estimate = {}".format( - np.abs(np.exp(-ln_evidence_analytic) - ev.evidence_inv) - / ev.evidence_inv - ) + " Aim for sqrt( 2/(n_eff-1) ) = {}".format(np.sqrt(2.0 / (ev.n_eff - 1))) ) # ===========================================================================