| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/mat/fun/autocorrelation.hpp>
5 #include <stan/math/prim/mat/fun/variance.hpp>
6 #include <vector>
7
8 namespace stan {
9 namespace math {
10
31 template <typename T>
32 void autocovariance(const std::vector<T>& y,
33 std::vector<T>& acov,
34 Eigen::FFT<T>& fft) {
35 autocorrelation(y, acov, fft);
36
37 T var = variance(y) * (y.size()-1) / y.size();
38 for (size_t i = 0; i < y.size(); i++) {
39 acov[i] *= var;
40 }
41 }
42
59 template <typename T>
60 void autocovariance(const std::vector<T>& y,
61 std::vector<T>& acov) {
62 Eigen::FFT<T> fft;
63 autocovariance(y, acov, fft);
64 }
65
66 }
67 }
68 #endif
variance.hpp
stan
Definition: log_sum_exp.hpp:8
autocorrelation.hpp
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:30
stan::math::variance
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
stan::math::autocovariance
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...
Definition: autocovariance.hpp:32
stan::math::autocorrelation
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...
Definition: autocorrelation.hpp:52

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