5#ifndef LINE_API_MAM_MAP_COUNT_VAR_H
6#define LINE_API_MAM_MAP_COUNT_VAR_H
56Matrix<T> map_count_deviation(
const Matrix<T>& D,
const std::vector<T>& theta) {
57 const std::size_t n = D.rows();
59 for (std::size_t i = 0; i < n; ++i)
60 for (std::size_t j = 0; j < n; ++j) A(i, j) = theta[j] - D(i, j);
76 "map_count_var requires transcendental arithmetic");
77 const std::size_t n = m.
order();
79 const std::vector<T> theta =
map_prob(m);
80 const Matrix<T> tmp = detail::map_count_deviation(D, theta);
81 const std::vector<T> e =
ones<T>(n);
83 const std::vector<T> thetaD1 =
vecmul(theta, m.
D1);
85 for (
const T& v : thetaD1) lam += v;
86 const std::vector<T> c =
vecmul(thetaD1, tmp);
89 const std::vector<T> cD1 =
vecmul(c, m.
D1);
91 for (
const T& v : cD1) cD1e += v;
93 const T linear = lam - two * lam * lam + two * cD1e;
96 out.reserve(t.size());
97 for (std::size_t k = 0; k < t.size(); ++k) {
99 throw InputError(
"map_count_var: negative window length");
102 const std::vector<T> cE =
vecmul(c, E);
104 for (std::size_t i = 0; i < n; ++i) corr += (c[i] - cE[i]) * d[i];
105 out.push_back(linear * t[k] - two * corr);
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.
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_count_var(const Map< T > &m, const std::vector< T > &t)
Variance of the counting process of a MAP at resolution t.
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 > inverse(const Matrix< T > &A)
Inverse by LU with one factorization and n back substitutions.
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