MESMER-group / mesmer

spatially-resolved ESM-specific multi-scenario initial-condition ensemble emulator
https://mesmer-emulator.readthedocs.io/en/latest/
GNU General Public License v3.0
23 stars 17 forks source link

optimize _draw_auto_regression_correlated_np #165

Open mathause opened 2 years ago

mathause commented 2 years ago

The function _draw_auto_regression_correlated_np can be optimized to run faster - there are some fun optimizations that can be made.

ar = np.einsum("ijk,jk->ik", out[:, t - ar_lags, :], coefs)

https://github.com/MESMER-group/mesmer/blob/0c5b26569c8f0929d20c84448e7c8dc3635aff25/mesmer/core/auto_regression.py#L72

out = innovations # copy-by-reference: use innovations as out param

https://github.com/MESMER-group/mesmer/blob/0c5b26569c8f0929d20c84448e7c8dc3635aff25/mesmer/core/auto_regression.py#L69

https://github.com/MESMER-group/mesmer/blob/0c5b26569c8f0929d20c84448e7c8dc3635aff25/mesmer/core/auto_regression.py#L74


Advanced optimizations:

mathause commented 1 year ago

Removing from the milestone again. This remains a not-critical good first issue.

mathause commented 1 year ago

I suspect that (2) & (3) are mutually exclusive.

mathause commented 1 year ago

For (5) this could be dispatched in draw_auto_regression_correlated (which still has to be written)

veni-vidi-vici-dormivi commented 7 months ago

For (5) we could a separate function for draw innovations, which would make the whole thing more intuitive. However, as mentioned, this was painstakingly unified, I'll look through the whole autoregression part, maybe I can come up with something nice, but as you said, it's not critical.