icecube / flarestack

Unbinned likelihood analysis code for astroparticle physics datasets
https://flarestack.readthedocs.io/en/latest/?badge=latest
MIT License
8 stars 7 forks source link

Multiply source weights into S/B matrix in one shot #396

Closed jvansanten closed 6 days ago

jvansanten commented 1 week ago

Multiplying a CSR matrix row-wise and then summing over rows is ~40x faster than masked assignments to a LIL matrix followed by a row-wise sum for 100 sources. For 1000 sources, the speedup is ~200x; for 10000, ~1900x (800 ms per gamma point vs 27 minutes). Who knew?

JannisNe commented 1 week ago

That's cool. Could that also be used in the StandardMatrixLLH?

sathanas31 commented 6 days ago

Quick answer is yes. For StandardMatrixLLH there is no gamma dependence of the signal spatial, so it corresponds to the first if statement in the StdMatrixKDEEnabledLLH where the SoB and weighting are decoupled