1 #ifndef STAN__PROB__AUTOCORRELATION_HPP
2 #define STAN__PROB__AUTOCORRELATION_HPP
9 #include <unsupported/Eigen/FFT>
21 size_t fft_next_good_size(
size_t N) {
25 while((m % 2) == 0) m /= 2;
26 while((m % 3) == 0) m /= 3;
27 while((m % 5) == 0) m /= 5;
64 size_t M = fft_next_good_size(N);
68 vector<complex<T> > freqvec;
71 vector<T> centered_signal(y);
72 centered_signal.insert(centered_signal.end(),Mt2-N,0.0);
74 for (
size_t i = 0; i < N; i++)
75 centered_signal[i] -= mean;
77 fft.fwd(freqvec,centered_signal);
78 for (
size_t i = 0; i < Mt2; ++i)
79 freqvec[i] = complex<T>(norm(freqvec[i]), 0.0);
101 for (
size_t i = 0; i < N; ++i) {
105 for (
size_t i = 0; i < N; ++i)
125 template <
typename T>
127 std::vector<T>& ac) {
boost::math::tools::promote_args< T >::type mean(const std::vector< T > &v)
Returns the sample mean (i.e., average) of the coefficients in the specified standard vector...
void autocorrelation(const std::vector< T > &y, std::vector< T > &ac, Eigen::FFT< T > &fft)
Write autocorrelation estimates for every lag for the specified input sequence into the specified res...