jmatta1 / MCMCpp

A C++ header only library that performs Markov chain Monte Carlo sampling in several forms.
MIT License
2 stars 0 forks source link

The calculation of integrated autocorrelation time is slow. #1

Open jmatta1 opened 6 years ago

jmatta1 commented 6 years ago

The MCMC::Analysis::AutoCorrCalc takes longer to calculate the integrated autocorrelation times than MCMC::EnsembleSampler<double, Mover::AutoRegressiveMove > took to calculate the chains in the test example.

jmatta1 commented 6 years ago

This is an unfortunate consequence of the somewhat more precise method I use to calculate the integrated autocorrelation time (IAT). In the method seen in emcee the chains are averaged before the IFFT( |FFT(Chain)|^2) step to get the "autocovariance function of the average walker". However, I calculate IFFT( |FFT(Chain)|^2) on each walker and average the outputs. This gives the "average autocovariance function of the walkers" a subtle difference that gives greater precision (tighter grouping) of the calculated IAT. However this means many more evaluations of the FFT and IFFT, which can be somewhat expensive.

This problem could be somewhat reduced by either switching to use the FFTW library (or similar) or by optimizing the FFT and IFFT that are used. Since I am trying to minimize the dependencies of MCMCpp so for now I am not using FFTW and because I do not have the time to learn and apply all the tricks necessary to make the Fast Fourier Transform into a Super Fast Fourier Transform, this will stand.

In time I may come back to this and try to make it faster.