Stan  1.0
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 
5 
6 namespace stan {
7 
8  namespace prob {
9 
10 
31  template <typename T>
32  void autocovariance(const std::vector<T>& y,
33  std::vector<T>& acov,
34  Eigen::FFT<T>& fft) {
35 
36  stan::prob::autocorrelation(y, acov, fft);
37 
38  T var = stan::math::variance(y) * (y.size()-1) / y.size();
39  for (size_t i = 0; i < y.size(); i++) {
40  acov[i] *= var;
41  }
42  }
43 
60  template <typename T>
61  void autocovariance(const std::vector<T>& y,
62  std::vector<T>& acov) {
63  Eigen::FFT<T> fft;
64  autocovariance(y,acov,fft);
65  }
66 
67 
68  }
69 }
70 
71 #endif

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