I am working on a C++ project that often requires the computation of Gaussian pdf given a data point x and an existing Gaussian distribution G.
This is expensive since the exponential function exp is involved. Even if I take log, the log function is costly as well. Any suggestions about how I can do it?
Vectorize it, that is, compute the exponents or logs in parallel using SIMD, you can also use optimized approximating SSE based
expandlogif you don’t need extreme accuracy, a simple lib for that can be found here.However, when it comes to optimizing, profile first, that way you fix the problem, not what you think is the problem.