I am working on an algorithm that requires a Gaussian function and a lot of loops.
The Boost::math::pdf has the correct formula that I need to implement.
I am creating a normal distribution with boost::math::normal_distribution normal_distribution(0,sigma) where the mean will always be zero and the sigma can vary at different times when the function is called.
I then want to use the function boost::math::pdf( normal_distribution , dsitance_from_mean ) in my loop to avoid reinventing the wheel with my own look up table. I read through the boost documentation looking for this answer, but I am not quite clear on how the function works.
Does the pdf function use a look up table generated with the normal distribution, or does it calculate the exponent value every time it is called?
My expectation would be that the Boost authors would prioritize accuracy over performance.
Browsing through the source code for the version I have installed, I see plenty of
calls to trig/log/exp functions, and nothing resembling lookup tables or interpolation,
so I think it’s calling exp() every time.
I would recommend benchmarking it yourself, to see if the Boost code is really a
performance bottleneck, before implementing your own lookup table.