All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
autocovariance.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_MAT_FUN_AUTOCOVARIANCE_HPP
#define STAN_MATH_PRIM_MAT_FUN_AUTOCOVARIANCE_HPP
#include <stan/math/prim/mat/fun/autocorrelation.hpp>
#include <stan/math/prim/mat/fun/variance.hpp>
#include <vector>
namespace stan {
namespace math {
template <typename T>
void autocovariance(const std::vector<T>& y,
std::vector<T>& acov,
Eigen::FFT<T>& fft) {
stan::math::autocorrelation(y, acov, fft);
T var = stan::math::variance(y) * (y.size()-1) / y.size();
for (size_t i = 0; i < y.size(); i++) {
acov[i] *= var;
}
}
template <typename T>
void autocovariance(const std::vector<T>& y,
std::vector<T>& acov) {
Eigen::FFT<T> fft;
autocovariance(y, acov, fft);
}
}
}
#endif
variance.hpp
autocorrelation.hpp
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:32
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:34
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:54

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