diff --git a/CHANGELOG.md b/CHANGELOG.md index ec0cfe802b41f22ba56ec3eecd5c35b48087c2ef..5f8b4a2bff34fd03c825857161f7cc040d56430d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - Ensure that best models are properly computed when models are computed by blocks and that no fit could be made in one or more blocks. This can be case if all the models in the block are older than the age of the universe. (Médéric) ### Optimised - Slight speedup of the computation of the likelihood from the χ² (Médéric Boquien) +- Speedup of the computation of the χ² by ~10% (Médéric Boquien) - The the fritz2006 module should now run faster thanks to an optimisation of the computation of the luminosity of the various AGN components (Médéric Boquien & Guang Yang) ## 2018.0 (2018-11-06) diff --git a/pcigale/analysis_modules/pdf_analysis/utils.py b/pcigale/analysis_modules/pdf_analysis/utils.py index ac1679de4340c281026f0677cb0124e686ff1f03..b3f0ce6c5b4e1b8ccfc186cf84bace0636561324 100644 --- a/pcigale/analysis_modules/pdf_analysis/utils.py +++ b/pcigale/analysis_modules/pdf_analysis/utils.py @@ -256,12 +256,12 @@ def compute_chi2(models, obs, corr_dz, wz, lim_flag): # inverse error inv_flux_err = 1. / obs.flux_err[band] model = models.flux[band][wz] - chi2 += ((flux - model * scaling) * inv_flux_err) ** 2. + chi2 += ((model * scaling - flux) * inv_flux_err) ** 2. # Computation of the χ² from intensive properties for name, prop in obs.intprop.items(): model = models.intprop[name][wz] - chi2 += ((prop - model) * (1. / obs.intprop_err[name])) ** 2. + chi2 += ((model - prop) * (1. / obs.intprop_err[name])) ** 2. # Computation of the χ² from extensive properties for name, prop in obs.extprop.items(): @@ -269,7 +269,7 @@ def compute_chi2(models, obs, corr_dz, wz, lim_flag): # inverse error inv_prop_err = 1. / obs.extprop_err[name] model = models.extprop[name][wz] - chi2 += ((prop - (scaling * model) * corr_dz) * inv_prop_err) ** 2. + chi2 += (((scaling * model) * corr_dz - prop) * inv_prop_err) ** 2. # Finally take the presence of upper limits into account if limits is True: