1 #ifndef STAN_MATH_PRIM_MAT_FUN_AUTOCORRELATION_HPP 2 #define STAN_MATH_PRIM_MAT_FUN_AUTOCORRELATION_HPP 5 #include <unsupported/Eigen/FFT> 17 size_t fft_next_good_size(
size_t N) {
21 while ((m % 2) == 0) m /= 2;
22 while ((m % 3) == 0) m /= 3;
23 while ((m % 5) == 0) m /= 5;
59 size_t M = fft_next_good_size(N);
62 vector<complex<T> > freqvec;
65 vector<T> centered_signal(y);
66 centered_signal.insert(centered_signal.end(), Mt2-N, 0.0);
68 for (
size_t i = 0; i < N; i++)
69 centered_signal[i] -= mean;
71 fft.fwd(freqvec, centered_signal);
72 for (
size_t i = 0; i < Mt2; ++i)
73 freqvec[i] = complex<T>(norm(freqvec[i]), 0.0);
95 for (
size_t i = 0; i < N; ++i) {
99 for (
size_t i = 0; i < N; ++i)
119 template <
typename T>
121 std::vector<T>& ac) {
Independent (input) and dependent (output) variables for gradients.
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...