Commit ad964607 authored by Médéric Boquien's avatar Médéric Boquien

Slightly rewrite the χ² formula to optimise the computation. It gains ~10% in speed.

parent 4303cb3d
......@@ -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)
......
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment