Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
autocovariance.hpp
Go to the documentation of this file.
1 #ifndef __STAN__PROB__AUTOCOVARIANCE_HPP__
2 #define __STAN__PROB__AUTOCOVARIANCE_HPP__
3 
6 
7 namespace stan {
8 
9  namespace prob {
10 
11 
32  template <typename T>
33  void autocovariance(const std::vector<T>& y,
34  std::vector<T>& acov,
35  Eigen::FFT<T>& fft) {
36 
37  stan::prob::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

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