SWIFTSIM / emulator

The SWIFT simulation cosmological emulator (swift-emulator)
GNU Lesser General Public License v3.0
5 stars 2 forks source link

Optionally skip returning the variance #48

Open MatthieuSchaller opened 1 month ago

MatthieuSchaller commented 1 month ago

Could we add an optional parameter to GaussianProcessEmulator.predict_values() which would switch on/off the computation of the variance? That would "just" require to pass return_var=False to the george GP object.

In my use case, returning the variance is 50x slower (60ms vs. 1.2ms) than not returning it. In an emulation MCMC scenario where the PS baryon ratio is just a small component, that is a critical difference.

Getting the full error is only necessary once the chain has converged and then switching on the variance return would suffice.

Happy to have a stab at it.

JBorrow commented 1 month ago

I don't like overloading the return values of a function based on an input parameter. But i am more than happy for you to write a predict_values_no_error() or similarly named function. You would need to add it to the abstract base class in base.py and then add corresponding versions to all of the associated classes in emulators/. It shouldn't be too bad.

MatthieuSchaller commented 1 month ago

Ok. I agree that having different numbers of outputs based on arguments is not great but seems common in the python world.

A separate function will work too. I'll do that.