5#ifndef LINE_API_MAM_MAP_VARCOUNT_H
6#define LINE_API_MAM_MAP_VARCOUNT_H
55 "map_varcount requires transcendental arithmetic");
56 const std::size_t n = m.
order();
58 const std::vector<T> piq =
map_prob(m);
59 const Matrix<T> tmp = detail::map_count_deviation(Q, piq);
61 const std::vector<T> e =
ones<T>(n);
62 const std::vector<T> D1e =
mulvec(m.
D1, e);
64 const std::vector<T> piD1 =
vecmul(piq, m.
D1);
66 for (
const T& v : piD1) lam += v;
68 const std::vector<T> piD1tmp =
vecmul(piD1, tmp);
70 for (std::size_t i = 0; i < n; ++i) pre_corr += piD1tmp[i] * D1e[i];
72 const T pre = lam - two * lam * lam + two * pre_corr;
74 const std::vector<T> tail =
mulvec(tmp2, D1e);
77 out.reserve(tset.size());
78 for (std::size_t k = 0; k < tset.size(); ++k) {
80 throw InputError(
"map_varcount: negative window length");
82 const std::vector<T> piD1E =
vecmul(piD1, E);
84 for (std::size_t i = 0; i < n; ++i) post += (piD1[i] - piD1E[i]) * tail[i];
85 out.push_back(pre * tset[k] - two * post);
The exception types the port throws.
Matrix exponential by scaling and squaring with a diagonal Pade approximant.
Dense linear algebra over the templated number type: products, identity, inverse, and powers.
Variance of the counting process of a MAP at resolution t.
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
Dense matrix and non-owning view.
Matrix< T > map_infgen(const Map< T > &m)
Generator of the underlying phase process, D0 + D1.
std::vector< T > map_varcount(const Map< T > &m, const std::vector< T > &tset)
Variance of the counts of a MAP over windows of length t, in the spelling of matlab/lib/kpctoolbox/ma...
std::vector< T > map_prob(const Map< T > &m)
Stationary distribution of the phase process, pi (D0 + D1) = 0.
std::vector< T > vecmul(const std::vector< T > &v, const Matrix< T > &A)
Row vector times matrix, v A.
Matrix< T > matmul(const Matrix< T > &A, const Matrix< T > &B)
Matrix product A B.
std::vector< T > mulvec(const Matrix< T > &A, const std::vector< T > &v)
Matrix times column vector, A v.
std::vector< T > ones(std::size_t n)
Column vector of ones, the ubiquitous e in MAP algebra.
Matrix< T > expm(const Matrix< T > &A)
Matrix exponential exp(A).
Number-type abstraction for the templated API port.
A MAP as the pair of matrices (D0, D1).
std::size_t order() const