Stan  1.0
probability, sampling & optimization
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
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: matrix.hpp:1053
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...
Probability, optimization and sampling library.
Definition: agrad.cpp:6

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