diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8c6d5da637a4ea596cd1fbae6376231a2e5155bf..d011258d52aea43d52ae1b34fd20c4369927aeb1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,9 +25,10 @@
- Some labels and the title for the SED plots has been improved to avoid overlaps and overflows. (Médéric Boquien)
- 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)
+- Slight speedup of the computation of the likelihood from the χ² using a multiplication rather than a division. (Médéric Boquien)
+- Speedup of the computation of the χ² by ~10% taking the opposite of a scalar rather than of an array. (Médéric Boquien)
- Thanks to a change in the layout of the models storage in RAM, the computation of the χ² is now massively faster when the run contains multiple redshifts. (Médéric Boquien)
+- The computation of the weighted means and standard deviations has been made ~50% faster by normalising the likelihood. (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 b3f0ce6c5b4e1b8ccfc186cf84bace0636561324..ce46b000d6db19127f5270974b30c958b5c66bbe 100644
--- a/pcigale/analysis_modules/pdf_analysis/utils.py
+++ b/pcigale/analysis_modules/pdf_analysis/utils.py
@@ -306,7 +306,7 @@ def weighted_param(param, weights):
"""
- mean = np.average(param, weights=weights)
- std = np.sqrt(np.average((param-mean)**2, weights=weights))
+ mean = np.sum(param * weights)
+ std = np.sqrt(np.sum((param - mean)**2 * weights))
return (mean, std)
diff --git a/pcigale/analysis_modules/pdf_analysis/workers.py b/pcigale/analysis_modules/pdf_analysis/workers.py
index 0e97e81c0365963b4c62652cbc55c26de0c6fed4..04d882e523c7dfe412430fc3455c006bfc8a88b3 100644
--- a/pcigale/analysis_modules/pdf_analysis/workers.py
+++ b/pcigale/analysis_modules/pdf_analysis/workers.py
@@ -168,6 +168,7 @@ def analysis(idx, obs):
scaling_l = scaling[wlikely]
gbl_results.bayes.weight[idx] = np.nansum(likelihood)
+ likelihood *= 1. / gbl_results.bayes.weight[idx]
# We compute the weighted average and standard deviation using the
# likelihood as weight.