Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
autocovariance.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_AUTOCOVARIANCE_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_AUTOCOVARIANCE_HPP
3 
6 #include <vector>
7 
8 namespace stan {
9 
10  namespace math {
11 
12 
33  template <typename T>
34  void autocovariance(const std::vector<T>& y,
35  std::vector<T>& acov,
36  Eigen::FFT<T>& fft) {
37  stan::math::autocorrelation(y, acov, fft);
38 
39  T var = stan::math::variance(y) * (y.size()-1) / y.size();
40  for (size_t i = 0; i < y.size(); i++) {
41  acov[i] *= var;
42  }
43  }
44 
61  template <typename T>
62  void autocovariance(const std::vector<T>& y,
63  std::vector<T>& acov) {
64  Eigen::FFT<T> fft;
65  autocovariance(y, acov, fft);
66  }
67 
68 
69  }
70 }
71 
72 #endif
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:32
boost::math::tools::promote_args< T >::type variance(const std::vector< T > &v)
Returns the sample variance (divide by length - 1) of the coefficients in the specified standard vect...
Definition: variance.hpp:24
void autocovariance(const std::vector< T > &y, std::vector< T > &acov, Eigen::FFT< T > &fft)
Write autocovariance estimates for every lag for the specified input sequence into the specified resu...
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...

     [ Stan Home Page ] © 2011–2015, Stan Development Team.