optimize_solution¶
- ell1fit.fitting.optimize_solution(observations, setup, nsteps=1000, minimize_first=False, outroots=('out',), reference_phases=None, sampler='emcee', nlive=1000, dlogz=0.1, workers=0)[source]¶
Optimize and sample pulsar timing parameters for multiple event files.
Workflow: 1. Build a posterior from priors + profile likelihood. 2. Optionally run deterministic minimization for a starting point. 3. Run MCMC with
safe_run_sampler(), or another backend – seesampler. 4. Produce diagnostic phaseogram comparisons and return summary fields.Parameters are handled in local coordinates: for each fitted parameter,
physical = local * factor + initial.- Parameters:
- sampler{“emcee”, “nuts”, “nested”}, optional
Which posterior-exploration backend to run.
"emcee"(the default) issafe_run_sampler(), unchanged from before this parameter existed."nuts"isell1fit.nuts_sampling.run_nuts(), needingpip install ell1fit[nuts]."nested"isell1fit.nested_sampling.run_nested(), needingpip install ell1fit[nested]– it is the only one of the three that reportslog_evidence, which is what an eccentricity Bayes factor needs and neither of the other two can give.- nlive, dlogz, workersoptional
Only consulted when
sampler="nested". Nested sampling can miss a narrow mode entirely and still report a confident, wrong evidence, sonlivematters more than it looks like it should – seeell1fit.nested_sampling.PEAK_SHORTFALL_GATE.workers– seeell1fit.nested_sampling.run_nested()– spreads likelihood evaluations across processes;0(the default) runs single-process.- reference_phaseslist of np.ndarray or None, optional
Phases to draw in the left-hand panel of the comparison phaseograms – the “before” of a before-and-after. Pass the phases of the solution the run started from.
This must be supplied by the caller rather than derived here. The obvious derivation, evaluating the posterior at local coordinates zero, silently means “whatever
setup.baseline_valuescurrently holds”, which is only the starting solution as long as nothing has re-centred the baseline in between. Iterative template refinement does exactly that, and the comparison then comes out as the refined solution against itself: two identical panels, and a diagnostic that always looks perfect. Defaults to the local-zero solution when omitted, which is correct only when no refinement has run.
- Returns:
- dict
Aggregated result dictionary containing posterior summaries, initial values, scaling factors, and copied model metadata.