Commit 2169d2e3 authored by Médéric Boquien's avatar Médéric Boquien

Use the Einstein summation convention to avoid the creation of temporary...

Use the Einstein summation convention to avoid the creation of temporary arrays when computing the likelihood-weighted means and standard deviations. This speeds up the evaluation of the physical properties and ultimately pdf_analysis can run more than 25% faster when evaluating a large number of physical properties with more than a million models.
parent 95b8cfd3
Pipeline #2894 skipped with stage
......@@ -9,6 +9,7 @@
- Ensure that `pcigale-plots` correctly detects the `skirtor2016` AGN models. (Médéric Boquien, reported by Guang Yang)
- Correct a typo in the `themis` module. (Médéric Boquien, reported by Alexandros Maragkoudakis)
### Optimised
- The estimation of the physical properties and the related uncertainties has been made up to 50% faster. The final gain in the analysis speed accounting for all the steps depends on the number of properties to be evaluated and the number of models but can be over 25% when estimating many properties over a large parameter space. (Médéric Boquien)
## 2020.0 (2020-06-29)
### Added
......
......@@ -304,7 +304,8 @@ def weighted_param(param, weights):
"""
mean = np.sum(param * weights)
std = np.sqrt(np.sum((param - mean)**2 * weights))
mean = np.einsum('i, i', param, weights)
delta = param - mean
std = np.sqrt(np.einsum('i, i, i', delta, delta, weights))
return (mean, std)
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