diff --git a/src/elisa/infer/results.py b/src/elisa/infer/results.py index 7f7db16..744c735 100644 --- a/src/elisa/infer/results.py +++ b/src/elisa/infer/results.py @@ -972,6 +972,10 @@ def _(p): fn_dic = {d: factory(d) for d in mapping.values()} + cov = self.covar(params=(), fn=fn_dic, method='hess') + std = {k: np.sqrt(cov.matrix[k, k]) for k in mapping.values()} + std = {k: std[v] for k, v in mapping.items()} + if method == 'profile': if params is not None: warnings.warn('params is ignored when using profile method') @@ -1028,6 +1032,7 @@ def _(p): return { 'mle': jax.tree.map(convert, mle_flux), + 'std': jax.tree.map(convert, std), 'intervals': jax.tree.map(convert, intervals), 'errors': jax.tree.map(convert, errors), 'cl': cl, @@ -2618,6 +2623,9 @@ class MLEFlux(NamedTuple): mle: dict[str, Q] | dict[str, dict[str, Q]] """The model flux at MLE.""" + std: dict[str, Q] | dict[str, dict[str, Q]] + """The errors of the model flux, calculated from Hessian matrix.""" + intervals: dict[str, tuple[Q, Q]] | dict[str, dict[str, tuple[Q, Q]]] """The confidence intervals of the model flux.""" @@ -2652,6 +2660,9 @@ class MLELumin(NamedTuple): mle: dict[str, Q] | dict[str, dict[str, Q]] """The model luminosity at MLE.""" + std: dict[str, Q] | dict[str, dict[str, Q]] + """The errors of the model luminosity, calculated from Hessian matrix.""" + intervals: dict[str, tuple[Q, Q]] | dict[str, dict[str, tuple[Q, Q]]] """The confidence intervals of the model luminosity.""" @@ -2687,7 +2698,10 @@ class MLEEiso(NamedTuple): """Cosmology model used to calculate Eiso.""" mle: dict[str, Q] | dict[str, dict[str, Q]] - r"""The model Eiso at MLE.""" + """The model Eiso at MLE.""" + + std: dict[str, Q] | dict[str, dict[str, Q]] + """The errors of the model Eiso, calculated from Hessian matrix.""" intervals: dict[str, tuple[Q, Q]] | dict[str, dict[str, tuple[Q, Q]]] """The confidence intervals of the model Eiso."""